Optimized std.datetime.date.Date.fromISOExtString#6062
Optimized std.datetime.date.Date.fromISOExtString#6062dlang-bot merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @JackStouffer! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
wilzbach
left a comment
There was a problem hiding this comment.
To save other reviewers time looking. to (or to be exact the underlying parse) does error checking itself, see
ac9ff8c to
b86a7f9
Compare
| auto signAtBegining = yearStr.startsWith('-', '+'); | ||
| if ((yearStr.length > 4 && !signAtBegining) || | ||
| (yearStr.length <= 4 && signAtBegining)) | ||
| throw new DateTimeException(format("Invalid ISO Extended String: %s", isoExtString)); |
There was a problem hiding this comment.
I hate to nitpick style, but would you please use braces if the condition is more than one line - either that or put the condition on a single line instead of breaking it up. IMHO, it's a readability problem if there are no braces when the condition is multiple lines.
There was a problem hiding this comment.
Also, aside from the optimizer being smart about things here (which it may be), I would expect it to be faster if you broke this up so that it didn't check the length twice given that it's the same check in reverse.
b86a7f9 to
55223b3
Compare
55223b3 to
54708e1
Compare
Removed explicit auto-decoding and simplified/speed up format checking.
Previous PRs: #5550 #5404 #5413
Results:
Code