Skip to content

Conversation

austinshenk
Copy link

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 elm/core#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.

@drathier
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants