4 ms·
This sounds kinda plausible. IIRC, some string implementations have separate implementations for very short strings vs. longer ones. Similar thing for vectors
by CoastalCoder 2y ago
This sounds kinda plausible.
IIRC, some string implementations have separate implementations for very short strings vs. longer ones. Similar thing for vectors.
I also see some size-related logic in the (current?) String implementation [0] [1].
String is a class with no virtual methods, and its first data member is a pointer to the underlying buffer [2]. So if Stream.printf unintentionally type-puns String to char*, it might work out okay?
[0] https://github.com/arduino/ArduinoCore-API/blob/master/api/String.cpp https://github.com/arduino/ArduinoCore-API/blob/master/api/S...
[1] https://github.com/arduino/ArduinoCore-API/blob/master/api/String.h https://github.com/arduino/ArduinoCore-API/blob/master/api/S...
[2] https://github.com/arduino/ArduinoCore-API/blob/cb3ab4c90d71d40c9c3f5a37bac0c274e8c89cbb/api/String.h#L220 https://github.com/arduino/ArduinoCore-API/blob/cb3ab4c90d71...
- CoastalCoder 2y agoAlthough sizeof(String) > sizeof(char*), so any subsequent arguments to printf(...) would probably be screwed up.