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

coalesce registering and unregistering options #147

Merged

Conversation

fivetanley
Copy link
Contributor

@fivetanley fivetanley commented Sep 14, 2016

tl;dr we can call the _setDefaultValues() function only once when rendering
a bunch of components or destroying a bunch of components.

If you have a list with a large amount of selects (~ 40 in our app),
the _setDefaultValues function can get pretty expensive as it has to query
the DOM every time. This gets slowly more costly to query as registering
40 <option> elements calls the _setDefaultValues function 40 times.

In addition to the 40 times the function is called, the number of
elements slowly grows as well. This ends up being n^2\2. After this PR, it's just 1 time.

tl;dr we can call the `_setDefaultValues()` function only once when rendering
a bunch of components or destroying a bunch of components.

If you have a list with a large amount of selects (~ >40 in our app),
the `_setDefaultValues` function can get pretty expensive as it has to query
the DOM every time. This gets slowly more costly to query as registering
40 `<option>` elements calls the `_setDefaultValues` function 40 times.

In addition to the 40 times the function is called, the number of
elements slowly grows as well. This ends up being O(n^2\2).
@Robdel12
Copy link
Collaborator

Love it!

@Robdel12 Robdel12 merged commit 9e4f871 into adopted-ember-addons:master Sep 14, 2016
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