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 :+1:
Yes, this sounds good! This code is pretty old. Would like to see some benchmarks around any perf oriented changes but certainly anything you think improves readability is more than welcome.
Hey @bendrucker, thanks for your work on this project!
I've re-implemented the parse function in PostGraphile, with the following changes (roughly):
(?:...)
in the wrapper-regexps to reduce the number of capture groups(\\d\\d(?:\\.\\d{1,6})?)
^...$
to ensure it matches the whole string{}
if!interval
. (Maybe this should returnnull
instead?)parseMilliseconds
function as it's no-longer necessaryreduce
loop, instead using unrolled simple assignmentWould 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 addmilliseconds
back in, at least).The result of this change would be:
If this is not of interest; feel free to close this issue :+1: