virtual-dom icon indicating copy to clipboard operation
virtual-dom copied to clipboard

Improve VDOM's iteration performance

Open austinshenk opened this issue 7 years ago • 1 comments

I went through and audited the for-loops and while-loops in VDOM's kernel code. I converted all of the forward iteration loops to use length - i instead of i < length and made sure the length value is being cached in a variable instead of being accessed each iteration. Example performance details are recorded in https://github.com/elm/core/pull/1000.

I plan to take the changes I made and compare some benchmarks to show the results. These changes should not be destructive to existing functionality since I've tested a number of functions already and have not found anything that compromises it.

austinshenk avatar Oct 24 '18 17:10 austinshenk

The length property of strings is immutable, so caching it will only slightly reduce performance in modern browsers; it's already constant time to access. < vs - should also not make a noticeable difference, as code will be specialized to ints by the jit compiler. It's better to keep the code easy to read imo.

drathier avatar Jun 19 '19 00:06 drathier