-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Hey @bendrucker, thanks for your work on this project!
I've re-implemented the parse function in PostGraphile, with the following changes (roughly):
- Uses
(?:...)in the wrapper-regexps to reduce the number of capture groups - Destructures from the matches in a straightforward way
- Changes the seconds/milliseconds to be captured as one group:
(\\d\\d(?:\\.\\d{1,6})?) - Pins the regexp with
^...$to ensure it matches the whole string - Returns a zero-interval rather than
{}if!interval. (Maybe this should returnnullinstead?) - Removes the
parseMillisecondsfunction as it's no-longer necessary - Removes the
reduceloop, instead using unrolled simple assignment
Would you like me to replicate these changes in a PR to postgres-interval? I'm pretty confident I can do it in a non-breaking way (it won't be a complete copy of the above code because I'll need to add milliseconds back in, at least).
The result of this change would be:
- slightly better performance
- slightly reduced memory usage
- more linear code
If this is not of interest; feel free to close this issue 👍
charmander
Metadata
Metadata
Assignees
Labels
No labels