WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
239464
Introduce makeAtomString()
https://bugs.webkit.org/show_bug.cgi?id=239464
Summary
Introduce makeAtomString()
Chris Dumez
Reported
2022-04-18 14:09:29 PDT
Introduce makeAtomString() which is an optimized version of makeString() when the caller knows it wants an AtomString. It may avoid a StringImpl allocation when the string is already in the AtomStringTable.
Attachments
Patch
(6.51 KB, patch)
2022-04-18 14:12 PDT
,
Chris Dumez
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(7.29 KB, patch)
2022-04-18 14:42 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(8.73 KB, patch)
2022-04-18 16:34 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(8.87 KB, patch)
2022-04-18 16:37 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(8.89 KB, patch)
2022-04-18 16:37 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(8.62 KB, patch)
2022-04-18 16:55 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2022-04-18 14:12:51 PDT
Created
attachment 457820
[details]
Patch
Chris Dumez
Comment 2
2022-04-18 14:42:56 PDT
Created
attachment 457824
[details]
Patch
Darin Adler
Comment 3
2022-04-18 15:17:45 PDT
Comment on
attachment 457824
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=457824&action=review
> Source/WTF/wtf/text/StringConcatenate.h:502 > + if (areAllAdapters8Bit) { > + LChar buffer[maxLengthToUseStackVariable]; > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + return AtomString { buffer, length }; > + } > + UChar buffer[maxLengthToUseStackVariable]; > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + return AtomString { buffer, length };
I wonder if the compiler is smart enough to not allocate both buffers.
> Source/WTF/wtf/text/StringConcatenate.h:525 > + if (areAllAdapters8Bit) { > + LChar* buffer; > + RefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer); > + if (!resultImpl) > + return nullAtom(); > + > + if (buffer) > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + > + return resultImpl.get(); > + } > + > + UChar* buffer; > + RefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer); > + if (!resultImpl) > + return nullAtom(); > + > + if (buffer) > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + > + return resultImpl.get();
Is there a way to share code with tryMakeStringFromAdapters here?
Chris Dumez
Comment 4
2022-04-18 16:34:50 PDT
Created
attachment 457836
[details]
Patch
Chris Dumez
Comment 5
2022-04-18 16:37:07 PDT
Created
attachment 457837
[details]
Patch
Chris Dumez
Comment 6
2022-04-18 16:37:44 PDT
Created
attachment 457838
[details]
Patch
Darin Adler
Comment 7
2022-04-18 16:51:54 PDT
Comment on
attachment 457838
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=457838&action=review
> Source/WebCore/svg/SVGLengthValue.cpp:30 > +#include <wtf/text/StringConcatenate.h> > #include <wtf/text/StringConcatenateNumbers.h>
I thought "StringConcatenateNumbers.h" included "StringConcatenate.h"
Chris Dumez
Comment 8
2022-04-18 16:52:51 PDT
(In reply to Darin Adler from
comment #7
)
> Comment on
attachment 457838
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=457838&action=review
> > > Source/WebCore/svg/SVGLengthValue.cpp:30 > > +#include <wtf/text/StringConcatenate.h> > > #include <wtf/text/StringConcatenateNumbers.h> > > I thought "StringConcatenateNumbers.h" included "StringConcatenate.h"
Oh, I think that was me trying to fix a build error the wrong way. I'll drop.
Chris Dumez
Comment 9
2022-04-18 16:55:32 PDT
Created
attachment 457841
[details]
Patch
Chris Dumez
Comment 10
2022-04-18 18:54:44 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 457824
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=457824&action=review
> > > Source/WTF/wtf/text/StringConcatenate.h:502 > > + if (areAllAdapters8Bit) { > > + LChar buffer[maxLengthToUseStackVariable]; > > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > > + return AtomString { buffer, length }; > > + } > > + UChar buffer[maxLengthToUseStackVariable]; > > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > > + return AtomString { buffer, length }; > > I wonder if the compiler is smart enough to not allocate both buffers.
Good question. I am not quite sure how to find out though.
Sam Weinig
Comment 11
2022-04-19 10:06:54 PDT
Comment on
attachment 457841
[details]
Patch Very nice.
EWS
Comment 12
2022-04-19 10:59:05 PDT
Committed
r293024
(
249763@main
): <
https://commits.webkit.org/249763@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 457841
[details]
.
Radar WebKit Bug Importer
Comment 13
2022-04-19 11:00:14 PDT
<
rdar://problem/91972473
>
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