mirror of
https://github.com/esphome/esphome.git
synced 2025-10-04 11:02:19 +01:00
[logger] Optimize log formatting performance (33-67% faster)
This commit is contained in:
@@ -315,13 +315,11 @@ class Logger : public Component {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper: copy fixed-length data to buffer and advance position
|
|
||||||
static inline void copy_and_advance(char *buffer, uint16_t &pos, const char *data, uint8_t len) {
|
static inline void copy_and_advance(char *buffer, uint16_t &pos, const char *data, uint8_t len) {
|
||||||
memcpy(buffer + pos, data, len);
|
memcpy(buffer + pos, data, len);
|
||||||
pos += len;
|
pos += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper: copy string to buffer and advance position (calculates length with strlen)
|
|
||||||
static inline void copy_string(char *buffer, uint16_t &pos, const char *str) {
|
static inline void copy_string(char *buffer, uint16_t &pos, const char *str) {
|
||||||
copy_and_advance(buffer, pos, str, strlen(str));
|
copy_and_advance(buffer, pos, str, strlen(str));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user