Conversation
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#12775
components: [kuntze]
refresh: 1h(Added by the PR bot) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #12775 +/- ##
==========================================
- Coverage 73.34% 73.31% -0.03%
==========================================
Files 53 53
Lines 11284 11284
Branches 1531 1531
==========================================
- Hits 8276 8273 -3
- Misses 2608 2610 +2
- Partials 400 401 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Memory Impact AnalysisComponents:
📊 Component Memory Breakdown
🔍 Symbol-Level Changes (click to expand)Changed Symbols
Removed Symbols (top 15)
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
|
👋 Hi there! I've automatically requested reviews from codeowners based on the files changed in this PR. @ssieb - You've been requested to review this PR as codeowner(s) of 1 file(s) that were modified. Thanks for your time! 🙏 |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the kuntze component's verbose logging by replacing heap-allocating format_hex_pretty(...).c_str() with stack-based format_hex_pretty_to(). This eliminates a std::string heap allocation in the logging path.
Key Changes:
- Added include for
esphome/core/helpers.hto access the stack-based formatting function - Introduced
KUNTZE_MAX_LOG_BYTESconstant (8 bytes) and allocated a 24-byte stack buffer for hex formatting - Replaced
format_hex_pretty(data).c_str()withformat_hex_pretty_to(hex_buf, data.data(), data.size())
|
Thanks |
What does this implement/fix?
Replace heap-allocating
format_hex_pretty(...).c_str()with stack-basedformat_hex_pretty_to()in the kuntze component's verbose logging.This eliminates a
std::stringheap allocation in the LOGV path. The buffer is wrapped in a compile guard to avoid stack allocation when verbose logging is disabled.Buffer size is 24 bytes (
format_hex_pretty_size(8)) based on typical Modbus response size (2 registers = 4 bytes data, plus overhead).Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: