WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
205759
Further simplify StringBuilder usage by standardizing hex formating to a single hex() function
https://bugs.webkit.org/show_bug.cgi?id=205759
Summary
Further simplify StringBuilder usage by standardizing hex formating to a sing...
Sam Weinig
Reported
2020-01-03 16:28:20 PST
Further simplify StringBuilder usage by standardizing hex formating to a single hex() function
Attachments
Patch
(25.27 KB, patch)
2020-01-03 16:38 PST
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(26.43 KB, patch)
2020-01-04 14:52 PST
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(32.41 KB, patch)
2020-01-04 15:38 PST
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2020-01-03 16:38:51 PST
Created
attachment 386729
[details]
Patch
Sam Weinig
Comment 2
2020-01-03 16:43:10 PST
Darin, you have been working in this area a bit, any thoughts on this simplification? It applies the mapping: appendByteAsHex(value, builder, case) -> builder.append(hex(static_cast<unsigned char>(value), 2, case)) appendUnsignedAsHex(value, builder, case) -> builder.append(hex(value, case)) appendUnsignedAsHexFixedSize(value, builder, size, case) -> builder.append(hex(value, size, case))
Darin Adler
Comment 3
2020-01-03 18:10:03 PST
(In reply to Sam Weinig from
comment #2
)
> appendByteAsHex(value, builder, case) > -> builder.append(hex(static_cast<unsigned char>(value), 2, case))
This seems a bit clumsy. But I suppose only a bit.
> appendUnsignedAsHex(value, builder, case) > -> builder.append(hex(value, case)) > appendUnsignedAsHexFixedSize(value, builder, size, case) > -> builder.append(hex(value, size, case))
These seem great to me. However, I don’t think we are being consistent in style. Sometimes we name these things: FormattedNumber::fixedWidth Other times we name something similar: hex We should decide what style we are after.
Sam Weinig
Comment 4
2020-01-04 12:21:22 PST
(In reply to Darin Adler from
comment #3
)
> (In reply to Sam Weinig from
comment #2
) > > appendByteAsHex(value, builder, case) > > -> builder.append(hex(static_cast<unsigned char>(value), 2, case)) > > This seems a bit clumsy. But I suppose only a bit. > > > appendUnsignedAsHex(value, builder, case) > > -> builder.append(hex(value, case)) > > appendUnsignedAsHexFixedSize(value, builder, size, case) > > -> builder.append(hex(value, size, case)) > > These seem great to me. However, I don’t think we are being consistent in > style. Sometimes we name these things: > > FormattedNumber::fixedWidth > > Other times we name something similar: > > hex > > We should decide what style we are after.
We definitely need to decide on the style. I am leaning toward the shorter, unqualified names (hex(...), pad(...), fixedWidth(...), fixedPrecision(...), etc), and putting them all in a shared header for easier discovery. I could be convinced having some qualifier namespace might be helpful, e.g. all in a Format namespace (Format::hex(...), Format::pad(...), etc). Do you have a particular preference?
Sam Weinig
Comment 5
2020-01-04 14:52:30 PST
Created
attachment 386768
[details]
Patch
Sam Weinig
Comment 6
2020-01-04 14:53:03 PST
I will unify the style with fixedWidth/fixedPrecision in a follow up.
Sam Weinig
Comment 7
2020-01-04 15:38:24 PST
Created
attachment 386771
[details]
Patch
Darin Adler
Comment 8
2020-01-04 20:08:05 PST
I like the short names for clarity at the point of use. I like the long names for searching the entire source tree to see where things are used.
Dean Jackson
Comment 9
2020-01-05 14:33:20 PST
Comment on
attachment 386771
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=386771&action=review
> Tools/TestWebKitAPI/Tests/WTF/HexNumber.cpp:34 > +// Not using builder.toString() or builder.toStringPreserveCapacity() because they all > +// change internal state of builder.
Why does that matter? You never use the builder again after the expect() method.
Sam Weinig
Comment 10
2020-01-05 15:22:35 PST
(In reply to Dean Jackson from
comment #9
)
> Comment on
attachment 386771
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=386771&action=review
> > > Tools/TestWebKitAPI/Tests/WTF/HexNumber.cpp:34 > > +// Not using builder.toString() or builder.toStringPreserveCapacity() because they all > > +// change internal state of builder. > > Why does that matter? You never use the builder again after the expect() > method.
Oh, that comment was copied from another test. That was silly of me.
WebKit Commit Bot
Comment 11
2020-01-05 16:20:10 PST
The commit-queue encountered the following flaky tests while processing
attachment 386771
[details]
: transitions/default-timing-function.html
bug 138901
(authors:
dino@apple.com
and
graouts@apple.com
) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 12
2020-01-05 16:21:05 PST
Comment on
attachment 386771
[details]
Patch Clearing flags on attachment: 386771 Committed
r254046
: <
https://trac.webkit.org/changeset/254046
>
WebKit Commit Bot
Comment 13
2020-01-05 16:21:07 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 14
2020-01-05 16:22:18 PST
<
rdar://problem/58328979
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug