Hypothesis
Split the debug() function into a thin wrapper and a separate enabledDebug() implementation. V8 optimizes smaller, monomorphic functions better.
Rationale
Current debug() is ~50 lines. Splitting into:
function debug() { if (!debug.enabled) return; return enabledDebug.call(debug, arguments); }
Makes the wrapper tiny. V8 can inline/optimize the disabled check aggressively. enabledDebug gets optimized separately for the hot path.
This also enables the arguments optimization (thesis #16) since the wrapper avoids rest parameter allocation on the disabled path.
Scope
- src/common.js createDebug(): extract enabled-path logic into enabledDebug
Expected impact
Moderate. V8 optimization for smaller functions + no rest param allocation on disabled path.
Risks
Must preserve public API properties on the debug function. enabledDebug accesses debug via closure or this.
Hypothesis
Split the debug() function into a thin wrapper and a separate enabledDebug() implementation. V8 optimizes smaller, monomorphic functions better.
Rationale
Current debug() is ~50 lines. Splitting into:
function debug() { if (!debug.enabled) return; return enabledDebug.call(debug, arguments); }
Makes the wrapper tiny. V8 can inline/optimize the disabled check aggressively. enabledDebug gets optimized separately for the hot path.
This also enables the arguments optimization (thesis #16) since the wrapper avoids rest parameter allocation on the disabled path.
Scope
Expected impact
Moderate. V8 optimization for smaller functions + no rest param allocation on disabled path.
Risks
Must preserve public API properties on the debug function. enabledDebug accesses debug via closure or this.