Closed bakkot closed 1 year ago
I don't think that after #86 this is required. Removed elements replaced via empty
, added again elements will not be visited since they are out of iteration range since the initial number of elements is cached.
The initial number of elements is not cached; it is updated each time through the loop (just like in Set.prototype.forEach
).
Ah, yes, I missed additional 1. Set _thisSize_ to the number of elements of _O_.[[SetData]].
step.
Fixes https://github.com/tc39/proposal-set-methods/issues/83.
There's actually two places the guard could go: before or after the call to
_otherRec_.[[Has]]
for this element. I initially put it before, which theoretically minimizes work (don't do the call if you don't need to), but have switched it to after on the assumption that actual engines won't need to do this as a separate step - they can just perform the "add to set" operation and it will not add a duplicate element.