angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

perf(copy): use different arrays for different types

Open lgalfaso opened this issue 11 years ago • 3 comments

Use different arrays for different types. Remove forEach to clean the destination object.

lgalfaso avatar Jun 09 '15 20:06 lgalfaso

using the same test at f7bf118ecaaab16ed8b3d16febb0ee6bb1d6749c, there is a 10% improvement

lgalfaso avatar Jun 09 '15 20:06 lgalfaso

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...

jbedard avatar Jun 09 '15 21:06 jbedard

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.

lgalfaso avatar Jun 09 '15 21:06 lgalfaso