There's a couple of ways that Component could possibly be made faster. This requires adding a few more functions to the codebase, which will likely increase the size from 2.2kb, to about 3kb.
Here are some of the speed and immutability improvements that can be made:
Replace spread operator - stuff like { ...ob1, ...obj2 } - with one of the following "immutable object copiers":
In all major browsers, replacing non-specified functions with NOOPs seems to be as fast or slightly faster than using conditions to only call the functions if they are specified. This is probably due to empty functions being optimized away. http://jsperf.com/noop-vs-condition
There's a couple of ways that
Component
could possibly be made faster. This requires adding a few more functions to the codebase, which will likely increase the size from 2.2kb, to about 3kb.Here are some of the speed and immutability improvements that can be made:
Replace spread operator - stuff like
{ ...ob1, ...obj2 }
- with one of the following "immutable object copiers":..also look into these:
Replace the
Component.eq
object comparison function with one of the following:Component.eq
can simply compare prev/next states with===
dequal/lite
is one of the very fastest around)Replace the
.uid
generation code with one of the following:Replace calls to native
Arrays
methods with these apparently faster alternatives:Memoize the "pure" functions inside
Component
, where possible:Optimise the
validator
add-on:Replace the
.freeze()
method with something faster:Fastest possible tweening?
From https://github.com/IceCreamYou/MainLoop.js/blob/gh-pages/src/mainloop.js#L100-L103: