Closed mathieucarbou closed 5 months ago
Well, I frankly prefer having just a few bytes allocated for my stat value, than 64 * 20 bytes for all the stats cards.
String is really helpfull in saving memory if it is used correctly.
One bad usage for example I often see:
void my_function(String foo)
instead of:
void my_function(String& foo)
or....
String a = "ggggg";
while(...) { a += "fff"; }
instead of:
String a;
a.reserve(...);
a += "ggggg";
while(...) { a += "fff"; }
operators have been override in the String class so +=
in this example won't cause a new memory allocation.
I guess, I started using char arrays instead of String because - one day I read an article which said String causes heap fragmentation and uses more bytes than it saves for little data.
Don't know if that's true, happy to hear your thoughts on it.