-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert Protocol names to shared text #1078
Conversation
* Saves about 400 bytes.
Thanks David. I'm surprised that Theo has a nice trick to save even more. In a nutshell, concatenate all strings of a specific type to a single string separate with
Then create an array of codes in parallel of the strings with the same indices:
Use the following for index to text (note the first string before the first
You can then have a strategy for matching similar to this one:
The magic is that it works backwards, scan This should save you a lot of code :) |
@s-hadinger Thanks. I'll take a look at doing just that. |
Interestingly, I tried using |
* Simplify the conversion of str <-> decode_type_t * Saves ~1.9k of flash * Kudos to @s-hadinger for the idea!
@s-hadinger It did. I did something simpler as I don't have the same issues as Tasmota. I could do what you guys do, and shave a few more bytes, but this way makes the code more readable. |
* Use a specially encoded string to store all the protocol names to save space. * Saves an additional 750+ bytes.
* Saves another 700+ bytes.
Another revision, this time removing redundant strings, & using a single double "null terminated" string to store the text. All in all, an additional 1.5k more saving. |
Wow. Great job. Let me try it in Tasmota |
I confirm it's working on Tasmota, no crash due to PROGMEM. It saves 3.4KB of flash. Do you plan to release a version v2.7.6 with the space saving feature? |
Yes, eventually. |
7 days have passed. No un-addressed negative feedback. Merging. |
_v2.7.6 (20200425)_ **[Features]** - IRMQTTServer: Use more i18n text. (#1086) - Convert Protocol names to shared text. Saves ~3k of flash. (#1078) - Add Chinese translation (zh-CN) & add utf-8 support. (#1080, #1085) **[Misc]** - IRMQTTServer: Ensure MQTT_MAX_PACKET_SIZE is correctly set. (#1084) - Add Italian locale to IRrecvDumpV2 platformio file.
_v2.7.6 (20200425)_ **[Features]** - IRMQTTServer: Use more i18n text. (#1086) - Convert Protocol names to shared text. Saves ~3k of flash. (#1078) - Add Chinese translation (zh-CN) & add utf-8 support. (#1080, #1085) **[Misc]** - IRMQTTServer: Ensure MQTT_MAX_PACKET_SIZE is correctly set. (#1084) - Add Italian locale to IRrecvDumpV2 platformio file.
FYI @s-hadinger