Files
react-native/packages
Tomislav Novak 13265ad636 Preserve order of elements after BoundedConsumableBuffer::clear() (#43679)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43679

The current implementation of clear-with-predicate first copies unconsumed
elements and then all others. This works correctly when the buffer is full
(wraps around), but fails if size() < maxSize: add() may no longer insert
an element in the correct position (after the last unconsumed entry; see
new unit test).

Replace it with a loop that iterates over all entries in order, and adjusts
cursorStart and cursorEnd to point to the last numToConsume elements of the
vector.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D55273402

fbshipit-source-id: 647dc35faeb35c7fa99b8113cf85ce7f02f073e5
2024-03-27 11:39:06 -07:00
..