Skip to content

Commit 21af2e8

Browse files
committed
perf: defer _cachedBuffers allocation in CachedSource
Follow-up to the _cachedSize deferral: PR #204 added a new `this._cachedBuffers = undefined` preallocation to the CachedSource constructor, which re-introduces the same per-construction cost we previously removed from RawSource/OriginalSource/SourceMapSource. `_cachedBuffers` is only read from `buffer()` and `buffers()`, and both call sites already guard with `!== undefined`, which treats missing properties identically to an undefined slot. Drop the eager assignment so every CachedSource construction skips one write and one hidden-class transition, and instances that never call `buffers()` stay on a tighter shape. https://claude.ai/code/session_01LZbaaPrnDTu6y7s4nK4cJz
1 parent 4d32b91 commit 21af2e8

1 file changed

Lines changed: 0 additions & 5 deletions

File tree

lib/CachedSource.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ class CachedSource extends Source {
142142
* @type {Buffer | undefined}
143143
*/
144144
this._cachedBuffer = cachedData ? cachedData.buffer : undefined;
145-
/**
146-
* @private
147-
* @type {Buffer[] | undefined}
148-
*/
149-
this._cachedBuffers = undefined;
150145
/**
151146
* @private
152147
* @type {number | undefined}

0 commit comments

Comments
 (0)