Či použiješ += alebo concat je v podstate fuk. v prípade AVR to vedie na to isté
https://github.com/arduino/ArduinoCore- ... String.cpp
Kód: Vybrat vše
StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(rhs.buffer, rhs.len)) a.invalidate();
return a;
}
https://github.com/esp8266/Arduino/blob ... String.cpp
To či použiješ makro F(" ") alebo nie má zase hovadský význam ak budeš mať AVR s 4kiBy SRAM.
Ak myslíš vyžitím pamäte to čo píše kompiler na konci tak macro F by si pocítiť mal. V mojej funkcii to bolo 12 byte dole z globálnej alokácie. To čo sa deje na heape tam samozrejme vidieť nie je. A to je ten problém. Ak nevieš ako heap pracuje tak si myslím že je to časovaná bomba
toľkoto o tom píšu napríklad v MISRA
Tiež nie som programátor. Programujem síce od 15 rokov ale nikdy som sa tým profesionálne neživil. Našťastie. Inak by som bol dnes asi totálne vyhoretý. Ale zase na druhej strane ma zaujíma ako to pracuje úplne na najnižšej úrovni.The use of dynamic memory can lead to out-of-storage run-time failures, which are undesirable.
The built-in new and delete operators, other than the placement versions, use dynamic heap memory. The functions calloc, malloc, realloc and free also use dynamic heap memory.
There is a range of unspecified, undefined and implementation-defined behaviour associated with dynamic memory allocation, as well as a number of other potential pitfalls. Dynamic heap memory allocation may lead to memory leaks, data inconsistency, memory exhaustion, non-deterministic behaviour, etc.
Note that some implementations may use dynamic heap memory allocation to implement other functions (for example, functions in the library cstring). If this is the case, then these functions shall also be avoided.