MitchellMarkGeorge / TabButler

A tab manager at your service.
https://tabbutler.netlify.app/
MIT License
43 stars 5 forks source link

Migrate to traditional for loops for performance boost #23

Closed MitchellMarkGeorge closed 2 years ago

MitchellMarkGeorge commented 2 years ago

Is your feature request related to a problem? Please describe. This isn't really a feature but after doing some (investigation)[https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/], I found that methods like forEach and map are pretty slow. I have noticed this is affecting things like on-install injection. This is really important as we are potentially dealing with huge arrays.

Describe the solution you'd like I would like to migrate some some forEarch and map usage in the project to traditional for loops to squeeze out as much performance as possible. I will start with the getTabsInCurrentWindow() method in background/utils as that is an essential part of the tab search.

Describe alternatives you've considered I have looked at for/in and for/of loops and they do perform quite well. I will keep them in mind when implementing a solution.

Additional context Refer to this link for more details: https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/

VladBrok commented 2 years ago

Hello, I would like to contribute on this

MitchellMarkGeorge commented 2 years ago

@VladBrok got right ahead! If you need any more context please reach out!

MitchellMarkGeorge commented 2 years ago

While #25 has been completed, I will leave this open for a bit in case we do some more work related to this.