Skip to content

Commit b1ec5cb

Browse files
committed
explain the implementation
1 parent 40718f3 commit b1ec5cb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/internal/fixed_queue.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const kMask = kSize - 1;
4949
// | undefined | | item |
5050
// +-----------+ +-----------+
5151
//
52+
// Implementation detail: To reduce allocations, a single spare
53+
// FixedCircularBuffer may be kept for reuse. When a segment empties it is
54+
// reset and stored as the spare, and when the head fills the spare is linked
55+
// in. This does not change the active list structure or queue semantics.
56+
//
5257
// Adding a value means moving `top` forward by one, removing means
5358
// moving `bottom` forward by one. After reaching the end, the queue
5459
// wraps around.

0 commit comments

Comments
 (0)