Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve VDOM's iteration performance #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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