Bug 217838

Summary: Extract StringImpl::computeHashAndFlags() function for passing to StringImplShape constructor
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Web Template FrameworkAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: NEW ---    
Severity: Normal CC: benjamin, cdumez, cmarcelo, darin, ews-watchlist, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 217805    
Bug Blocks:    
Attachments:
Description Flags
Patch v1
none
Patch v1 redo darin: review+

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>