alitaheri / jss-rtl

Flip styles using rtl-css-js
MIT License
83 stars 5 forks source link

Performance problem in large code bases because of using delete #5

Closed HosseinAgha closed 4 years ago

HosseinAgha commented 6 years ago

A JavaScript delete operator is used here this operator is super slow specially in V8 engine and it has just recently improved a little (take look here).
This creates a serious performance bottleneck for large applications with hundreds of classes and styles.
I'd be happy to contribute if you please explain the reason of deleteing the flip property.
Can we simply assign undefined to it? using lodash.omit is also another option. Also I think there is a isProcessed property on the rule parameter. Can we use it if delete is only for preventing duplicate flip?

alitaheri commented 6 years ago

@HosseinAgha It might not be a problem anymore, but from what I can remember, having undefined property would crash rtl-css-js. omit shallow clones the object. not sure if that would be better for performance. at the time, delete seemed to be the best option. I don't know if it still is or not.

If you wanna contribute, I'd happily accept, but please write a tiny bench mark before doing so and see which option actually improves performance. thank you