You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding items to a dropdown in mulitple batches the propagateSelected method takes considerable time to run and becomes slower with a higher number of items.
To reproduce create a dropdown and add items to the dropdown in batches. Amount of items something like 100, 200, 300, ... When you check the performance you will notice the propagateSelected taking more and more time to execute. The reason for this is that the propagateSelected method does a loop for every item in the oldItems list over the complete list of the newItems which makes this a O(n^2) algorithm.
There are different ways to improve this:
Only match selected items would solve my use case since typically the amount of selected items is a lot lower than the total amount of items.
Ideally we would like to do a fast lookup in a Dictionary based on a lookup key (eg the stringified object). But this doesn't look straightforward because matching items is currently being done on a substring of the stringified object. However I don't get why this is done. Maybe someone can explain the reasoning of this? If we could drop this substring requirement a very fast lookup in a Dictionary would become possible.
Carbon Design System: 5.26.0
The text was updated successfully, but these errors were encountered:
koenvd
changed the title
PropagateSelected being slow when adding lot's items to a dropdown in multiple batches
PropagateSelected being slow when adding lot's of items to a dropdown in multiple batches
Jul 1, 2024
koenvd
changed the title
PropagateSelected being slow when adding lot's of items to a dropdown in multiple batches
PropagateSelected becoming slow when adding lot's of items to a dropdown in multiple batches
Jul 1, 2024
koenvd
added a commit
to koenvd/carbon-components-angular
that referenced
this issue
Jul 1, 2024
Description
When adding items to a dropdown in mulitple batches the
propagateSelected
method takes considerable time to run and becomes slower with a higher number of items.To reproduce create a dropdown and add items to the dropdown in batches. Amount of items something like 100, 200, 300, ... When you check the performance you will notice the
propagateSelected
taking more and more time to execute. The reason for this is that thepropagateSelected
method does a loop for every item in theoldItems
list over the complete list of thenewItems
which makes this a O(n^2) algorithm.There are different ways to improve this:
Carbon Design System: 5.26.0
The text was updated successfully, but these errors were encountered: