-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Optimize SqlString.format #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I was looking for ways to speed up mysql.format after noticing that the performance was very slow when attempting to format a query with 100,000+ values. I came up with a couple of improvements, but by far the most significant is using an iterator to step through the values array instead of Array.shift(). See: http://jsperf.com/some-array-reading-comparisons/6
May fix #937 |
This sounds good to me, but please make sure that the |
Or nevermind my statement above; :) I'll doube-check that for realz and most likely I'll merge your code :O |
Never mind sentence above. It had nothing to do with this change, I was mistaken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for array copying, as you're not modifying it anymore. More win :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronkorving feel free to make a PR :) And remember that the values
argument may not always be an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, I missed that it can be an object too. Then there's nothing to gain here. My bad.
I was looking for ways to speed up mysql.format after noticing that the performance was very slow when attempting to format a query with 100,000+ values. I came up with a couple of improvements, by far the most significant is to use an iterator to step through the values array instead of Array.shift(). See: http://jsperf.com/some-array-reading-comparisons/6