mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-13 19:36:26 +03:00
comments
This commit is contained in:
@@ -51,13 +51,13 @@ uint32_t EMSESP::last_fetch_ = 0;
|
||||
AsyncWebServer webServer(80);
|
||||
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
FS dummyFS;
|
||||
auto& fsRef = dummyFS;
|
||||
FS dummyFS;
|
||||
auto & fsRef = dummyFS;
|
||||
#else
|
||||
auto& fsRef = LittleFS;
|
||||
auto & fsRef = LittleFS;
|
||||
#endif
|
||||
|
||||
ESP32React EMSESP::esp32React(&webServer, &fsRef);
|
||||
ESP32React EMSESP::esp32React(&webServer, &fsRef);
|
||||
WebSettingsService EMSESP::webSettingsService = WebSettingsService(&webServer, &fsRef, EMSESP::esp32React.getSecurityManager());
|
||||
WebCustomizationService EMSESP::webCustomizationService = WebCustomizationService(&webServer, &fsRef, EMSESP::esp32React.getSecurityManager());
|
||||
WebSchedulerService EMSESP::webSchedulerService = WebSchedulerService(&webServer, &fsRef, EMSESP::esp32React.getSecurityManager());
|
||||
@@ -919,7 +919,6 @@ std::string EMSESP::pretty_telegram(const std::shared_ptr<const Telegram> & tele
|
||||
}
|
||||
}
|
||||
|
||||
// Optimized: Use stack buffer and build string once to avoid multiple temporary allocations
|
||||
char buf[250];
|
||||
if (telegram->operation == Telegram::Operation::RX_READ) {
|
||||
auto pos = snprintf(buf,
|
||||
|
||||
@@ -34,7 +34,6 @@ char * Helpers::hextoa(char * result, const uint8_t value) {
|
||||
}
|
||||
|
||||
// same as hextoa but uses to a hex std::string
|
||||
// Optimized: Avoid string concatenation to reduce temporary allocations
|
||||
std::string Helpers::hextoa(const uint8_t value, bool prefix) {
|
||||
if (prefix) {
|
||||
char buf[5]; // "0x" + 2 hex chars + null
|
||||
@@ -60,7 +59,6 @@ char * Helpers::hextoa(char * result, const uint16_t value) {
|
||||
}
|
||||
|
||||
// same as above but to a hex string
|
||||
// Optimized: Avoid string concatenation to reduce temporary allocations
|
||||
std::string Helpers::hextoa(const uint16_t value, bool prefix) {
|
||||
if (prefix) {
|
||||
char buf[7]; // "0x" + 4 hex chars + null
|
||||
@@ -114,7 +112,6 @@ char * Helpers::ultostr(char * ptr, uint32_t value, const uint8_t base) {
|
||||
|
||||
// fast itoa returning a std::string
|
||||
// http://www.strudel.org.uk/itoa/
|
||||
// Optimized: Use stack buffer to avoid heap allocation, then create string once
|
||||
std::string Helpers::itoa(int16_t value) {
|
||||
// int16_t max: -32768 to 32767 = max 6 chars + null
|
||||
char buf[8];
|
||||
@@ -140,7 +137,7 @@ std::string Helpers::itoa(int16_t value) {
|
||||
/*
|
||||
* fast itoa
|
||||
* written by Lukás Chmela, Released under GPLv3. http://www.strudel.org.uk/itoa/ version 0.4
|
||||
* optimized for ESP32
|
||||
* optimized for ESP32 for EMS-ESP
|
||||
*/
|
||||
char * Helpers::itoa(int32_t value, char * result, const uint8_t base) {
|
||||
// check that the base if valid
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
// find tokens - optimized to reduce string allocations
|
||||
// find tokens
|
||||
std::deque<Token> exprToTokens(const std::string & expr) {
|
||||
std::deque<Token> tokens;
|
||||
|
||||
@@ -231,7 +231,7 @@ std::deque<Token> exprToTokens(const std::string & expr) {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
// sort tokens to RPN form - optimized for memory usage
|
||||
// sort tokens to RPN form
|
||||
std::deque<Token> shuntingYard(const std::deque<Token> & tokens) {
|
||||
std::deque<Token> queue;
|
||||
std::vector<Token> stack;
|
||||
@@ -347,7 +347,6 @@ bool isnum(const std::string & s) {
|
||||
std::string commands(std::string & expr, bool quotes) {
|
||||
auto expr_new = Helpers::toLower(expr);
|
||||
for (uint8_t device = 0; device < EMSdevice::DeviceType::UNKNOWN; device++) {
|
||||
// Optimized: build string with reserve to avoid temporary allocations
|
||||
std::string d;
|
||||
d.reserve(32); // typical device name length + "/"
|
||||
d = EMSdevice::device_type_2_device_name(device);
|
||||
@@ -374,8 +373,7 @@ std::string commands(std::string & expr, bool quotes) {
|
||||
JsonDocument doc_in;
|
||||
JsonObject output = doc_out.to<JsonObject>();
|
||||
JsonObject input = doc_in.to<JsonObject>();
|
||||
// Optimized: use stack buffer for small strings to avoid heap allocation
|
||||
char cmd_s[COMMAND_MAX_LENGTH + 5]; // "api/" prefix + cmd
|
||||
char cmd_s[COMMAND_MAX_LENGTH + 5]; // "api/" prefix + cmd
|
||||
snprintf(cmd_s, sizeof(cmd_s), "api/%s", cmd);
|
||||
|
||||
auto return_code = Command::process(cmd_s, true, input, output);
|
||||
|
||||
Reference in New Issue
Block a user