Open issy123 opened 6 years ago
Just for some historical context, the reason I did it this way was because there actually were GC pause issues with allocating a new object. reset()
is a hot function that is run multiple times each frame, which if it allocates generated a lot of garbage very quickly.
The compromise was to be slightly slower to run, but consistent. Rather than sometimes being faster, but spiking on GC.
Well it is significant faster I my experience with node v6+.
What would you suggest?
I always suggest measuring it, a benchmark suite that proves one thing or another is faster is always great.
We need a benchmark for many browsers and different versions of nodejs for this one :/ .
Looping through all object keys to delete them is very inefficient, rather remove the reference to the object and create a new object. The garbage collector is efficient enough to handle this.