SmingHub / Sming

Sming - powerful open source framework simplifying the creation of embedded C++ applications.
https://sming.readthedocs.io
GNU Lesser General Public License v3.0
1.48k stars 346 forks source link

Improve FlashString portability #2796

Closed mikee47 closed 5 months ago

mikee47 commented 5 months ago

This PR removes copy support from the FlashString library. Doing so simplifies the code, improves performance and portability to other compilers (e.g. clang).

The FlashString library previously supported copies (references) like this::

 FlashString emptyString;
 FlashString stringCopy(FS("Inline string"));

 DEFINE_FSTR_DATA_LOCAL(flashHelloData, "Hello");
 auto myCopy = flashHelloData;

These will now fail to compile. Copy construction and assignment has been explicitly deleted so avoid unintentional side-effects. Objects should always be passed by reference.

This change has the additional benefit of catching pass-by-copy errors. These function/method templates have been fixed:

slaff commented 5 months ago

@mikee47 can you add this information also to the UPGRADING document?

mikee47 commented 5 months ago

@mikee47 can you add this information also to the UPGRADING document?

? Already there...