Bug 213440 - Convert DateComponents parsing code to use Optional based return values rather than out-parameters
Summary: Convert DateComponents parsing code to use Optional based return values rathe...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-20 17:12 PDT by Sam Weinig
Modified: 2020-07-03 09:45 PDT (History)
9 users (show)

See Also:


Attachments
Patch (42.66 KB, patch)
2020-06-20 17:26 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (42.66 KB, patch)
2020-06-20 17:33 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (42.85 KB, patch)
2020-06-20 17:49 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (42.92 KB, patch)
2020-06-20 20:44 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (43.48 KB, patch)
2020-06-21 06:21 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (43.48 KB, patch)
2020-06-21 08:09 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (43.42 KB, patch)
2020-07-03 08:21 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2020-06-20 17:12:02 PDT
Convert DateComponents code parsing code to use Optional based return values rather than out-parameters
Comment 1 Sam Weinig 2020-06-20 17:26:46 PDT Comment hidden (obsolete)
Comment 2 Sam Weinig 2020-06-20 17:33:57 PDT Comment hidden (obsolete)
Comment 3 Sam Weinig 2020-06-20 17:49:54 PDT Comment hidden (obsolete)
Comment 4 Sam Weinig 2020-06-20 20:44:40 PDT Comment hidden (obsolete)
Comment 5 Sam Weinig 2020-06-21 06:21:53 PDT Comment hidden (obsolete)
Comment 6 Sam Weinig 2020-06-21 08:09:01 PDT
Created attachment 402425 [details]
Patch
Comment 7 Darin Adler 2020-06-21 12:50:20 PDT
Comment on attachment 402425 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402425&action=review

> Source/WebCore/html/BaseDateAndTimeInputType.cpp:81
> +    return !value.isEmpty() && parseToDateComponents(value) == WTF::nullopt;

I think !parse reads better than parse == nullopt. But I suppose others might argue that the ! one looks like it’s about 0; not for me. (As an aside, I hope we change our style to allow "== 0" at some point.)

> Source/WebCore/html/BaseDateAndTimeInputType.h:58
> +    virtual Optional<DateComponents> setMillisecondToDateComponents(double) const = 0;

What does the word "set" refer to in this (already existing, not new to this patch) function name?

> Source/WebCore/platform/DateComponents.cpp:116
> +    const CharacterType* current = src + parseStart;
> +    const CharacterType* end = current + parseLength;

I just woulda done auto for these.

> Source/WebCore/platform/DateComponents.cpp:201
> +    return createFromString(source, [] (auto& date, const auto* src, auto length, auto& end) {

Not a big fan of the use of the string "src" here. Also I think just auto src would do, no need for const auto*.
Comment 8 Darin Adler 2020-06-21 12:50:50 PDT
Comment on attachment 402425 [details]
Patch

Even though I had comments I think I will set commit-queue+, probably good to land this as-is.
Comment 9 EWS 2020-06-21 12:58:30 PDT
Committed r263331: <https://trac.webkit.org/changeset/263331>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402425 [details].
Comment 10 Radar WebKit Bug Importer 2020-06-21 12:59:16 PDT
<rdar://problem/64578366>
Comment 11 Jason Lawrence 2020-06-22 08:26:40 PDT
Reverted r263331 for reason:

This commit was causing 50+ iOS debug tests to crash.

Committed r263349: <https://trac.webkit.org/changeset/263349>
Comment 12 Sam Weinig 2020-07-03 08:21:32 PDT
Created attachment 403461 [details]
Patch
Comment 13 Sam Weinig 2020-07-03 08:22:02 PDT
(In reply to Sam Weinig from comment #12)
> Created attachment 403461 [details]
> Patch

Now with the missing empty string check added back.
Comment 14 EWS 2020-07-03 09:45:34 PDT
Committed r263900: <https://trac.webkit.org/changeset/263900>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403461 [details].