mirror of
https://github.com/esphome/esphome.git
synced 2026-02-20 08:25:35 -07:00
Optimize get_config_hash to avoid repeated snprintf calls
Check if hash string is already formatted before calling snprintf, since static variables in BSS are zero-initialized.
This commit is contained in:
@@ -34,7 +34,9 @@ static uintptr_t build_time = (uintptr_t) &ESPHOME_BUILD_TIME;
|
||||
|
||||
const char *get_config_hash() {
|
||||
static char hash_str[9];
|
||||
snprintf(hash_str, sizeof(hash_str), "%08x", (uint32_t) config_hash);
|
||||
if (!hash_str[0]) {
|
||||
snprintf(hash_str, sizeof(hash_str), "%08x", (uint32_t) config_hash);
|
||||
}
|
||||
return hash_str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user