1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-25 05:03:52 +01:00

[core] Optimize fnv1_hash to avoid string allocations for static entities (#10529)

This commit is contained in:
J. Nick Koston
2025-09-02 21:17:14 -05:00
committed by GitHub
parent e3fb9c2a78
commit 1a054299d4
4 changed files with 22 additions and 8 deletions

View File

@@ -155,7 +155,8 @@ uint16_t crc16be(const uint8_t *data, uint16_t len, uint16_t crc = 0, uint16_t p
bool refout = false);
/// Calculate a FNV-1 hash of \p str.
uint32_t fnv1_hash(const std::string &str);
uint32_t fnv1_hash(const char *str);
inline uint32_t fnv1_hash(const std::string &str) { return fnv1_hash(str.c_str()); }
/// Return a random 32-bit unsigned integer.
uint32_t random_uint32();