-
Notifications
You must be signed in to change notification settings - Fork 160
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
path.digits #272
path.digits #272
Conversation
src/path/string.js
Outdated
let i = 1; | ||
this._ += strings[0]; | ||
for (const j = strings.length; i < j; ++i) { | ||
this._ += +arguments[i].toFixed(digits) + strings[i]; |
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.
We might need additional coercion here if the stream is passed non-numeric input.
I did some benchmarking in https://observablehq.com/d/07584fd387781785 and learned some things.
So, I’d like to use the Math.round approach. We learned six years ago in d3/d3-path#10 (comment) that Math.round is faster than number.toFixed, so I’m just repeating that lesson here. |
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.
Nice!
Related d3/d3-path#11 which also adopted string concatenation over array.join for faster performance. |
Fixes #271. Related d3/d3-path#12.