-
Notifications
You must be signed in to change notification settings - Fork 811
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
Faster time parsing (~93% faster) #3860
Conversation
3c11b3a
to
aa490c0
Compare
I plan to review this carefully tomorrow if no on else had had a chance to do so |
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.
Looks very cool to me -- nice work @tustvold
I had several more suggested test cases but otherwise I think this PR looks 👨🍳 👌
It is hard to beat 97% improvement ❤️
("13:00 PM", "%I:%M %P"), | ||
("1:00:30.123456 PM", "%I:%M:%S%.f %P"), | ||
("1:00:30.123456789 PM", "%I:%M:%S%.f %P"), | ||
("1:00:30.123456789123 PM", "%I:%M:%S%.f %P"), |
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.
Given the experience with #3859, I think it would be valuable to include a time that has 4 and 7 significant digit (aka not a multiple of three)
("1:00:30.1234 PM", "%I:%M:%S%.f %P"),
("1:00:30.123456 PM", "%I:%M:%S%.f %P"),
Perhaps?
#[test] | ||
fn test_string_to_time_invalid() { | ||
let cases = [ | ||
"25:00", |
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.
I recommend also testing space and leading colon
" 9:00:00",
":09:00",
```
Perhaps also with a leading T (in case someone splits a RFC timestamp incorrectly)
```
"T9:00:00",
```
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.
Also just AM
"AM",
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.
Also, very long subseconds:
("1:00:30.123456789123456789 PM")
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.
Also intermediate non digits:
"1:00:30.12F456 PM",
arrow-cast/src/parse.rs
Outdated
|
||
_ => &[], | ||
let (am, bytes) = match bytes.get(bytes.len() - 3..) { | ||
Some(b" AM") => (Some(true), &bytes[..bytes.len() - 3]), |
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.
Are Am
and Pm
valid? If not, perhaps we can add a test showing that
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.
Turns out this is yet another case of chrono doing something differently from what it is documented to do.... Will fix...
Some(b" am") => (Some(true), &bytes[..bytes.len() - 3]), | ||
Some(b" PM") => (Some(false), &bytes[..bytes.len() - 3]), | ||
Some(b" pm") => (Some(false), &bytes[..bytes.len() - 3]), | ||
Some(b" AM" | b" am" | b" Am" | b" aM") => { |
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.
👍
Which issue does this PR close?
Closes #3919
Rationale for this change
Faster time parsing
What changes are included in this PR?
Are there any user-facing changes?