Skip to content
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

perf: faster sanitize date #131

Merged
merged 2 commits into from
Dec 14, 2023
Merged

perf: faster sanitize date #131

merged 2 commits into from
Dec 14, 2023

Conversation

andrewvasilchuk
Copy link
Contributor

Use String#slice instead of String#replace since it is ~20% faster in this particular case according to this performance test.

Use `String#slice` instead of `String#replace` since it is ~15% faster in this particular case
@iheanyi
Copy link
Member

iheanyi commented Aug 14, 2023

Going to close this one out. We only want to use replace in the sense that if the Z exists at the end, remove it. With this change, we're losing precision if the string doesn't contain the timezone.

@iheanyi iheanyi closed this Aug 14, 2023
@andrewvasilchuk
Copy link
Contributor Author

@iheanyi thanks for the feedback. Following MDN Date.prototype.toISOString() and ECMAScript Language Specification, a date string, returned from the Date#toISOString method always contain a "Z" char at the end.

@iheanyi
Copy link
Member

iheanyi commented Aug 14, 2023

Good point, that's a good call then. I'll reopen this then

@iheanyi iheanyi reopened this Aug 14, 2023
@ayrton ayrton enabled auto-merge December 14, 2023 13:03
@ayrton
Copy link
Contributor

ayrton commented Dec 14, 2023

Thank you

@ayrton ayrton merged commit 1c02bdf into planetscale:main Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants