feat: implement template processor for dynamic HTML variable replacement and optimize static asset serving with caching

This commit is contained in:
Manuel Weiser committed 2026-03-29 10:44:22 +02:00
1 parent 0f8d3d470d
commit a3dd4b164e
4 files changed
+49 -51

No files matched your search

+12 -2
View File
@@ -57,10 +57,20 @@ String readFile(const char* filename) {
Serial.println(filename);
return "";
}
String content = "";
// Effizient: Speicher vorab allokieren und in Blöcken lesen
// Alte Implementierung war O(n²) wegen Byte-für-Byte String-Konkatenation
size_t fileSize = file.size();
String content;
content.reserve(fileSize + 1); // Speicher vorab allokieren
// Lese in 512-Byte Blöcken statt Byte für Byte
char buffer[512];
while (file.available()) {
content += (char)file.read();
size_t bytesRead = file.readBytes(buffer, sizeof(buffer));
content.concat(buffer, bytesRead);
}
file.close();
return content;
}