Repository navigation
Replies: 11 comments
|
True |
0 replies
|
sadly include() do not accept regex as argument so indexOf() is the faster way for regex search |
0 replies
|
Yup, it will really optimize the code if we are able to apply it too all codes |
0 replies
|
cant think of any better way to optimize the code, will reopen when I have the time to research new ways |
0 replies
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment







Uh oh!
There was an error while loading. Please reload this page.
Hey, I will like to suggest to use includes() instate of indexOf() in your code when you are checking if the item exist. include() will be better in that case as you do not use the return int value of indexOf(), all you want is true or false which is what include() return.
Since it return true or false, equal operator is not needed (improve performance) and it is a Boolean (1 bit) which use lesser memory compare to int which is 16 bit.
Here is a performance test that I did: https://www.measurethat.net/Benchmarks/ShowResult/215464
All reactions