Repository navigation
Description
Goal
Skip the "Channel_<id>" auto-naming work in release builds where the resulting name is only consumed by no-op'd FL_WARN/FL_ERROR diagnostics. Drops fl::to_string instantiation + string concatenation from fl::Channel::Channel(...) and fl::Channel::create(...).
Parent: #2886 — small tactical win on top of the cumulative session work.
Why this is a real win
fl::Channel::Channel(...) at src/fl/channels/channel.cpp.hpp:195 initializes mName(makeName(mId)) in its member initializer list. makeName at src/fl/channels/channel.cpp.hpp:156-161:
fl::string Channel::makeName(i32 id, const fl::optional<fl::string>& configName) {
if (configName.has_value()) {
return configName.value();
}
return "Channel_" + fl::to_string(static_cast<i64>(id));
}The "Channel_" + fl::to_string(static_cast<i64>(id)) path runs for every channel constructed without an explicit name (which is every legacy addLeds<> flow). It pulls in:
fl::to_string(i64)— typically a switch + per-digit conversionfl::string::operator+(const char*, fl::string)— heap allocation + concatenation- The
fl::stringmove-out frommakeName's return
For release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0), mName is consumed only by FL_WARN / FL_ERROR sites that all expand to do { } while(0) per #2890. The name never reaches println/sstream — every read site dead-strips.
The remaining mName reads — passed to ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder, mSettings.rgbw(), mSettings.rgbww(), mName) at src/fl/channels/channel.cpp.hpp:499 — also feed into the iterator's own FL_WARN sites. Same logic applies: empty mName is fine in release.
Deliverable
src/fl/channels/channel.cpp.hpp — gate the auto-naming
fl::string Channel::makeName(i32 id, const fl::optional<fl::string>& configName) {
if (configName.has_value()) {
return configName.value();
}
#if FASTLED_LOG_RUNTIME_ENABLED
return "Channel_" + fl::to_string(static_cast<i64>(id));
#else
(void)id;
return {};
#endif
}User-provided names (via Channel::create(cfg) with cfg.mName.has_value()) are unaffected — they keep their explicit value in both debug and release builds.
Behavior matrix
| Build | configName set? | mName value |
|---|---|---|
Debug (FASTLED_LOG_VERBOSITY=1) |
yes | configName.value() |
| Debug | no | "Channel_<id>" |
Release (FASTLED_LOG_VERBOSITY=0) |
yes | configName.value() |
| Release | no | "" (empty) |
The release-build "Channel ''" rendering doesn't appear anywhere because the FL_WARN/FL_ERROR sites that would emit it are all collapsed to no-ops per Stage 1.
Acceptance
Channel::makeNamegated onFASTLED_LOG_RUNTIME_ENABLED.bash lint --cpppasses.- Behavior preserved in debug builds.
- Measured saving validated on post-merge build; baseline ratchets if positive.
Expected savings
Projected ~100-300 B. The fl::to_string + string concat + heap allocation path is non-trivial but small. The dead-strip cascade pattern from #2918 / #2925 / #2929 may push this higher if fl::to_string<i64> was reachable only from this site.
Out of scope
- Removing
mNameas a field. Public API (Channel::getName()). - Gating the FL_WARN/FL_ERROR sites that read mName. Already collapsed by Stage 1.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + audit cycle.
- perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890 — Stage 1 (the
FASTLED_LOG_VERBOSITY=0default this gate piggybacks on). - perf(esp32): gate emit* cold helpers on FASTLED_LOG_RUNTIME_ENABLED (~800 B) #2918 / fix(esp32): correct FASTLED_ASSERT release no-op + ratchet baseline 344769 -> 340832 #2925 — gating patterns for diagnostic-only paths.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(channel): skip auto-naming in release builds (#2942) (#2943)