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
Thanks for this great library! My application can potentially be running ‘substr’ on many long strings at the same time, so perf is very important. I noticed that ‘substr’ (etc) uses ‘match’ which runs the RegExp on the entire string. This can be quite expensive for long string especially if ‘substr’s ‘length’ is much shorter than the entire string.
So far I only have one idea: to use ‘exec’ with a while loop in the case that ‘length’ is much shorter than the entire ‘string’*. Do you have any other ideas for perf improvements? I would be happy to implement them and send you PRs.
Hello @sallar,
Thanks for this great library! My application can potentially be running ‘substr’ on many long strings at the same time, so perf is very important. I noticed that ‘substr’ (etc) uses ‘match’ which runs the RegExp on the entire string. This can be quite expensive for long string especially if ‘substr’s ‘length’ is much shorter than the entire string.
So far I only have one idea: to use ‘exec’ with a while loop in the case that ‘length’ is much shorter than the entire ‘string’*. Do you have any other ideas for perf improvements? I would be happy to implement them and send you PRs.
*See benchmarks: https://jsperf.com/regex-exec-vs-match-for-long-strings/1
Thanks
The text was updated successfully, but these errors were encountered: