Hypothesis
The enabled path writes self.diff, self.prev, and self.curr on every call (common.js lines 77-79). Only self.diff is read by formatArgs. Removing self.prev and self.curr writes and replacing them with lazy getters reduces per-call overhead.
Rationale
formatArgs reads this.diff (via humanize(this.diff)). .prev and .curr are public API but never read internally. Removing 2 property writes per call eliminates 400K assignments per benchmark run.
To preserve API compatibility, replace the eager writes with lazy getters backed by the prevTime closure variable and the curr local.
Scope
- src/common.js lines 77-79: remove self.prev and self.curr writes
- src/common.js createDebug function: add getters for .prev and .curr that return the closure values
Expected impact
Small. Property writes are cheap individually but compound over 200K calls.
Risks
Must preserve .prev and .curr as readable properties. Lazy getters using Object.defineProperty are safe for Node >= 6.
Hypothesis
The enabled path writes self.diff, self.prev, and self.curr on every call (common.js lines 77-79). Only self.diff is read by formatArgs. Removing self.prev and self.curr writes and replacing them with lazy getters reduces per-call overhead.
Rationale
formatArgs reads this.diff (via humanize(this.diff)). .prev and .curr are public API but never read internally. Removing 2 property writes per call eliminates 400K assignments per benchmark run.
To preserve API compatibility, replace the eager writes with lazy getters backed by the prevTime closure variable and the curr local.
Scope
Expected impact
Small. Property writes are cheap individually but compound over 200K calls.
Risks
Must preserve .prev and .curr as readable properties. Lazy getters using Object.defineProperty are safe for Node >= 6.