perf(copy): use different arrays for different types
Use different arrays for different types. Remove forEach to clean the destination object.
using the same test at f7bf118ecaaab16ed8b3d16febb0ee6bb1d6749c, there is a 10% improvement
I haven't created a PR yet but see ec8d48835a74b8ccb468193c1a8e28ed50d9e415. It reduces the copy time by 30-60% while also splitting the method up similar to this.
I didn't think of separate arrays though. But I'm not sure if it's worth the extra code and duplication imo. I'd still vote for using Map, but that had its own issues...
The use of Map would be ideal, but is not present in all the supported browsers and adding a polyfill would add a lot of code.