RESOLVED FIXED 150022
Add helper function for checking pointer equivalency and use it
https://bugs.webkit.org/show_bug.cgi?id=150022
Summary Add helper function for checking pointer equivalency and use it
Simon Fraser (smfr)
Reported 2015-10-11 21:47:35 PDT
Add helper funtion for checking pointer equivalency and use it
Attachments
Patch (31.18 KB, patch)
2015-10-11 21:57 PDT, Simon Fraser (smfr)
no flags
Patch (36.23 KB, patch)
2015-10-12 22:12 PDT, Simon Fraser (smfr)
no flags
Patch (37.73 KB, patch)
2015-10-12 22:56 PDT, Simon Fraser (smfr)
darin: review+
Simon Fraser (smfr)
Comment 1 2015-10-11 21:57:25 PDT
Simon Fraser (smfr)
Comment 2 2015-10-11 21:58:21 PDT
Not sure if RefPtr.h is the best place for bool areEquivalent(const T* a, const T* b), and it would be nice to have a unique_ptr version. Where to put it?
Alexey Proskuryakov
Comment 3 2015-10-11 23:17:51 PDT
Comment on attachment 262877 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=262877&action=review > Source/WTF/ChangeLog:3 > + Add helper funtion for checking pointer equivalency and use it Where does this use of the word "equivalency" originate from? I'm not familiar with it, and it looks quite misleading to me.
Simon Fraser (smfr)
Comment 4 2015-10-12 08:14:40 PDT
It was used in the style code quite a bit: - && shadowDataEquivalent(o) - && willChangeDataEquivalent(o) - && reflectionDataEquivalent(o) - && animationDataEquivalent(o) - && transitionDataEquivalent(o) + && areEquivalent(m_counterDirectives.get(), o.m_counterDirectives.get()) + && areEquivalent(m_boxShadow.get(), o.m_boxShadow.get()) + && areEquivalent(m_willChange, o.m_willChange) + && areEquivalent(m_boxReflect, o.m_boxReflect) + && areEquivalent(m_animations.get(), o.m_animations.get()) + && areEquivalent(m_transitions.get(), o.m_transitions.get())
Darin Adler
Comment 5 2015-10-12 16:59:52 PDT
Comment on attachment 262877 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=262877&action=review > Source/WTF/wtf/RefPtr.h:223 > +template<typename T> inline bool areEquivalent(const T* a, const T* b) > +{ > + return a == b || (a && b && *a == *b); > +} Should just implement this for all types instead of just pointers: template<typename T> inline bool areEquivalent(const T& a, const T& b) { return a == b || (a && b && *a == *b); } Then you don’t need a RefPtr overload. I suggest putting this somewhere in the WebCore tree instead of in WTF and naming it something more like isPointedToDataEqual.
Simon Fraser (smfr)
Comment 6 2015-10-12 17:03:52 PDT
I'm not sure I can handle that singular use of data :)
Simon Fraser (smfr)
Comment 7 2015-10-12 18:11:28 PDT
We like arePointingToEqualData().
Simon Fraser (smfr)
Comment 8 2015-10-12 22:12:05 PDT
Simon Fraser (smfr)
Comment 9 2015-10-12 22:13:00 PDT
I put it in WTF because there's place in WebCore for shared, non-platform-specific utilities, and we may want to use it in JSC or WebKit.
Simon Fraser (smfr)
Comment 10 2015-10-12 22:56:11 PDT
Darin Adler
Comment 11 2015-10-13 09:27:12 PDT
Comment on attachment 262973 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=262973&action=review > Source/WebCore/rendering/style/FillLayer.cpp:157 > + return arePointingToEqualData(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition I believe there is no need for the .get() here since arePointingToEqualData works on smart pointers too, not just raw pointers. > Source/WebCore/rendering/style/RenderStyle.cpp:559 > - if (rareNonInheritedData->m_grid.get() != other.rareNonInheritedData->m_grid.get() > - || rareNonInheritedData->m_gridItem.get() != other.rareNonInheritedData->m_gridItem.get()) > + if (rareNonInheritedData->m_grid != other.rareNonInheritedData->m_grid > + || rareNonInheritedData->m_gridItem != other.rareNonInheritedData->m_gridItem) Too bad we don’t have test cases for this bug fix. > Source/WebCore/rendering/style/RenderStyle.cpp:943 > + if (arePointingToEqualData(rareNonInheritedData->m_willChange.get(), willChangeData.get())) I believe there is no need for the .get() here since arePointingToEqualData works on smart pointers too, not just raw pointers.
Simon Fraser (smfr)
Comment 12 2015-10-13 09:34:32 PDT
(In reply to comment #11) > Comment on attachment 262973 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=262973&action=review > > > Source/WebCore/rendering/style/FillLayer.cpp:157 > > + return arePointingToEqualData(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition > > I believe there is no need for the .get() here since arePointingToEqualData > works on smart pointers too, not just raw pointers. I'll fix. > > Source/WebCore/rendering/style/RenderStyle.cpp:559 > > - if (rareNonInheritedData->m_grid.get() != other.rareNonInheritedData->m_grid.get() > > - || rareNonInheritedData->m_gridItem.get() != other.rareNonInheritedData->m_gridItem.get()) > > + if (rareNonInheritedData->m_grid != other.rareNonInheritedData->m_grid > > + || rareNonInheritedData->m_gridItem != other.rareNonInheritedData->m_gridItem) > > Too bad we don’t have test cases for this bug fix. Yes! > > Source/WebCore/rendering/style/RenderStyle.cpp:943 > > + if (arePointingToEqualData(rareNonInheritedData->m_willChange.get(), willChangeData.get())) > > I believe there is no need for the .get() here since arePointingToEqualData > works on smart pointers too, not just raw pointers. These are different types (PassRefPtr vs RefPtr), so the .get() are needed to turn both into raw pointers.
Simon Fraser (smfr)
Comment 13 2015-10-13 17:15:36 PDT
Note You need to log in before you can comment on or make changes to this bug.