WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
215830
HashMap<Ref<T>>::take should return RefPtr<T>
https://bugs.webkit.org/show_bug.cgi?id=215830
Summary
HashMap<Ref<T>>::take should return RefPtr<T>
Ryosuke Niwa
Reported
2020-08-25 16:50:36 PDT
HashMap<Ref<T>>::take should return RefPtr<T> instead of Optional<Ref<T>>.
Attachments
Patch
(20.98 KB, patch)
2020-08-25 17:33 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Patch for landing
(21.17 KB, patch)
2020-08-25 18:41 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2020-08-25 17:33:59 PDT
Created
attachment 407253
[details]
Patch
Darin Adler
Comment 2
2020-08-25 18:05:30 PDT
Comment on
attachment 407253
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=407253&action=review
Looks like an improvement at almost every call site.
> Source/WTF/wtf/HashTraits.h:215 > + typedef RefPtr<P> TakeType;
Since we’re touching it we could use using instead of typedef.
> Source/WebCore/dom/ScriptRunner.cpp:102 > - ASSERT(m_pendingAsyncScripts.contains(pendingScript)); > - m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(pendingScript)->ptr()); > + auto script = m_pendingAsyncScripts.take(pendingScript); > + ASSERT(script); > + m_scriptsToExecuteSoon.append(script.releaseNonNull());
This is an example where the "after" looks worse because releaseNonNull is such a long function name. But I see that there was reference count churn in the old version! No need to assert non-null separately before calling releaseNonNull, because that asserts. I would write this as a one-liner, I think.
Ryosuke Niwa
Comment 3
2020-08-25 18:40:54 PDT
(In reply to Darin Adler from
comment #2
)
> Comment on
attachment 407253
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=407253&action=review
> > Looks like an improvement at almost every call site. > > > Source/WTF/wtf/HashTraits.h:215 > > + typedef RefPtr<P> TakeType; > > Since we’re touching it we could use using instead of typedef.
Fixed. I'm gonna also fix PeekType.
> > Source/WebCore/dom/ScriptRunner.cpp:102 > > - ASSERT(m_pendingAsyncScripts.contains(pendingScript)); > > - m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(pendingScript)->ptr()); > > + auto script = m_pendingAsyncScripts.take(pendingScript); > > + ASSERT(script); > > + m_scriptsToExecuteSoon.append(script.releaseNonNull()); > > This is an example where the "after" looks worse because releaseNonNull is > such a long function name. But I see that there was reference count churn in > the old version! > > No need to assert non-null separately before calling releaseNonNull, because > that asserts. I would write this as a one-liner, I think.
Sure, I'd use the one liner.
Ryosuke Niwa
Comment 4
2020-08-25 18:41:24 PDT
Created
attachment 407256
[details]
Patch for landing
EWS
Comment 5
2020-08-25 19:25:10 PDT
Committed
r266157
: <
https://trac.webkit.org/changeset/266157
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 407256
[details]
.
Radar WebKit Bug Importer
Comment 6
2020-08-25 19:26:17 PDT
<
rdar://problem/67774006
>
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