Bug 217838 - Extract StringImpl::computeHashAndFlags() function for passing to StringImplShape constructor
Summary: Extract StringImpl::computeHashAndFlags() function for passing to StringImplS...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on: 217805
Blocks:
  Show dependency treegraph
 
Reported: 2020-10-16 12:22 PDT by David Kilzer (:ddkilzer)
Modified: 2020-10-23 12:23 PDT (History)
6 users (show)

See Also:


Attachments
Patch v1 (8.43 KB, patch)
2020-10-16 12:24 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch v1 redo (8.43 KB, patch)
2020-10-16 13:07 PDT, David Kilzer (:ddkilzer)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2020-10-16 12:22:03 PDT
Extract StringImpl::computeHashAndFlags() function for passing to StringImplShape constructor.

This is a follow-on to Darin's comments in Bug 217805 Comment #9.
Comment 1 David Kilzer (:ddkilzer) 2020-10-16 12:24:43 PDT
Created attachment 411604 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2020-10-16 12:26:24 PDT
(In reply to David Kilzer (:ddkilzer) from comment #1)
> Created attachment 411604 [details]
> Patch v1

LOL...posted this patch too soon.  Fix for Bug 217805 hasn't landed yet.
Comment 3 David Kilzer (:ddkilzer) 2020-10-16 13:07:05 PDT
Created attachment 411606 [details]
Patch v1 redo
Comment 4 Darin Adler 2020-10-16 13:49:36 PDT
Comment on attachment 411606 [details]
Patch v1 redo

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

> Source/WTF/wtf/text/StringImpl.h:213
> +    static constexpr unsigned computeHashAndFlags(unsigned hashBase, StringKind stringKind, BufferOwnership bufferOwnership, unsigned extraBits = 0)

Not thrilled with passing in "hashBase", which is effectively also an enumeration, as an untyped unsigned.

> Source/WTF/wtf/text/StringImpl.h:1240
> +        computeHashAndFlags(s_hashFlag8BitBuffer | s_hashFlagDidReportCost, stringKind, BufferInternal, (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount)), ConstructWithConstExpr)

Don’t need those parentheses around the last argument. Needed them before because they were part of an expression, but after a comma it’s not helpful, and in fact it makes it harder to read!
Comment 5 David Kilzer (:ddkilzer) 2020-10-16 16:14:09 PDT
Comment on attachment 411606 [details]
Patch v1 redo

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

>> Source/WTF/wtf/text/StringImpl.h:213
>> +    static constexpr unsigned computeHashAndFlags(unsigned hashBase, StringKind stringKind, BufferOwnership bufferOwnership, unsigned extraBits = 0)
> 
> Not thrilled with passing in "hashBase", which is effectively also an enumeration, as an untyped unsigned.

The more I stare at `enum BufferOwnership` and `enum StringKind`, the more I realize that they're really all just StringAttributes, and probably should be a single enum with an OptionSet<>.

Will think about this some more before landing.

>> Source/WTF/wtf/text/StringImpl.h:1240
>> +        computeHashAndFlags(s_hashFlag8BitBuffer | s_hashFlagDidReportCost, stringKind, BufferInternal, (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount)), ConstructWithConstExpr)
> 
> Don’t need those parentheses around the last argument. Needed them before because they were part of an expression, but after a comma it’s not helpful, and in fact it makes it harder to read!

Will do.
Comment 6 Radar WebKit Bug Importer 2020-10-23 12:23:14 PDT
<rdar://problem/70629961>