Bug 239022 - Update listMarkerTextForNodeAndPosition() to return a StringView instead of a String
Summary: Update listMarkerTextForNodeAndPosition() to return a StringView instead of a...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-08 17:09 PDT by Chris Dumez
Modified: 2022-04-10 19:30 PDT (History)
13 users (show)

See Also:


Attachments
Patch (8.32 KB, patch)
2022-04-08 17:12 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (8.32 KB, patch)
2022-04-10 16:28 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-04-08 17:09:32 PDT
Update listMarkerTextForNodeAndPosition() to return a StringView instead of a String. listMarkerTextForNodeAndPosition() has a StringView internally and none it its call sites actually need a String. The call sites either use StringBuilder or want a NSString*.
This avoids unnecessary String allocations.
Comment 1 Radar WebKit Bug Importer 2022-04-08 17:09:44 PDT
<rdar://problem/91509602>
Comment 2 Chris Dumez 2022-04-08 17:12:13 PDT
Created attachment 457129 [details]
Patch
Comment 3 Darin Adler 2022-04-10 15:54:12 PDT
Comment on attachment 457129 [details]
Patch

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

> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:684
> +    [[attrString mutableString] appendString:text.createNSString().get()];

This could almost certainly be createNSStringWIthoutCopying() since mutable string functions take characters out of NSString objects, they don’t keep the NSString around.
Comment 4 Chris Dumez 2022-04-10 16:04:52 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 457129 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457129&action=review
> 
> > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:684
> > +    [[attrString mutableString] appendString:text.createNSString().get()];
> 
> This could almost certainly be createNSStringWIthoutCopying() since mutable
> string functions take characters out of NSString objects, they don’t keep
> the NSString around.

Ok. The previous code was actually using a createNSStringWithoutCopying() but looking at the doc for appendString:, I couldn't convince myself that it was safe.

I'll go back to a createNSStringWithoutCopying() then.
Comment 5 Chris Dumez 2022-04-10 16:28:48 PDT
Created attachment 457217 [details]
Patch
Comment 6 EWS 2022-04-10 18:33:33 PDT
Committed r292693 (249485@main): <https://commits.webkit.org/249485@main>

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