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.47k stars 348 forks source link

Extend `CsvReader` capabilities, move into new library #2805

Closed mikee47 closed 3 months ago

mikee47 commented 3 months ago

This PR extends the capabilities CsvReader class, introduced in #2403.

Goals:

The code has been moved into a separate library.

Changes:

Fix String move to avoid de-allocating buffers

Use longer of two buffers for result. Example:

String s1 = "Greater than SSO buffer length";
String s2;
s1 = ""; // Buffer remains allocated
s2 = std::move(s1); // The move we need to fix

At present this move will result in s1's buffer being de-allocated. This can lead to performance degratation due to subsequent memory reallocations where a String is being passed around as a general buffer.

This change uses the larger of the two buffers when deciding how to behave. Checks added to HostTests to enforce predictable behaviour.

Add CStringArray::release method

Allows efficient conversion to a regular String object for manipulation.

Fix CStringArray operator+=

Must take reference, not copy - inefficient and fails when used with FlashString.

Move CsvReader into separate library

The CsvReader class has been moved out of Core/Data and into CsvReader which has additional capabilities. Changes to existing code:

TODO: