dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

[DI] Improve performance of algorithm to find probe scriptId

Open watson opened this issue 1 year ago • 4 comments

Warning: High risk of bikeshedding!

This might very well be overkill, but while I was refactoring this code recently, I was thinking of ways to use a Map instead of an array to store the reference between the script URL and the script ID.

This is the algorithm that I came up with.

This is not a very hot code-path as it's only hit every time a new probe is added. So it's not really necessary. So in the end this comes down to code readability and maintainability: And I can't really determine if it makes the code more readable/maintainable or worse.

What do you think?

watson avatar Sep 26 '24 11:09 watson