Skip to content

Commit de3d258

Browse files
Earle F. Philhower, IIIEarle F. Philhower, III
authored andcommitted
Add Small String Optimization, min String size
Reduce String memory overhead from 24 bytes to 16 bytes by limiting the maximum string length to <64Kbytes (which is larger than heap so no effective problem). Add Small String Optimization, SSO, which instead of allocating pointers to small strings on the heap will store the string in place of the pointer in the class. This should reduce memory fragmentation as Strings of 0-3 characters will not need extra malloc()s. No user code changes should be required to work with this optimization.
1 parent 5e4c2e9 commit de3d258

File tree

3 files changed

+155
-102
lines changed

3 files changed

+155
-102
lines changed

cores/esp8266/StreamString.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
size_t StreamString::write(const uint8_t *data, size_t size) {
2727
if(size && data) {
2828
if(reserve(length() + size + 1)) {
29-
memcpy((void *) (buffer + len), (const void *) data, size);
29+
memcpy((void *) (wbuffer() + len), (const void *) data, size);
3030
len += size;
31-
*(buffer + len) = 0x00; // add null for string end
31+
*(wbuffer() + len) = 0x00; // add null for string end
3232
return size;
3333
}
3434
}

0 commit comments

Comments
 (0)