[webkit-reviews] review granted: [Bug 215830] HashMap<Ref<T>>::take should return RefPtr<T> : [Attachment 407253] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 25 18:05:30 PDT 2020


Darin Adler <darin at apple.com> has granted Ryosuke Niwa <rniwa at webkit.org>'s
request for review:
Bug 215830: HashMap<Ref<T>>::take should return RefPtr<T>
https://bugs.webkit.org/show_bug.cgi?id=215830

Attachment 407253: Patch

https://bugs.webkit.org/attachment.cgi?id=407253&action=review




--- Comment #2 from Darin Adler <darin at apple.com> ---
Comment on attachment 407253
  --> https://bugs.webkit.org/attachment.cgi?id=407253
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.


More information about the webkit-reviews mailing list