Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Unified Diff: Source/core/dom/ElementDataCache.cpp

Issue 273843003: [Oilpan]: Make StylePropertySet fully garbage collected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix mac build Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/ElementDataCache.cpp
diff --git a/Source/core/dom/ElementDataCache.cpp b/Source/core/dom/ElementDataCache.cpp
index 8bdbf92705ec81566275a4a8322153701b983fdc..f4d761711a586801b14b8227bf20aba1de3c2f65 100644
--- a/Source/core/dom/ElementDataCache.cpp
+++ b/Source/core/dom/ElementDataCache.cpp
@@ -43,20 +43,19 @@ inline bool hasSameAttributes(const Vector<Attribute>& attributes, ShareableElem
return !memcmp(attributes.data(), elementData.m_attributeArray, attributes.size() * sizeof(Attribute));
}
-PassRefPtr<ShareableElementData> ElementDataCache::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
+PassRefPtrWillBeRawPtr<ShareableElementData> ElementDataCache::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
{
ASSERT(!attributes.isEmpty());
- ShareableElementDataCache::ValueType* it = m_shareableElementDataCache.add(attributeHash(attributes), nullptr).storedValue;
-
+ ShareableElementData* elementData = m_shareableElementDataCache.get(attributeHash(attributes));
// FIXME: This prevents sharing when there's a hash collision.
- if (it->value && !hasSameAttributes(attributes, *it->value))
+ if (elementData && !hasSameAttributes(attributes, *elementData))
return ShareableElementData::createWithAttributes(attributes);
- if (!it->value)
- it->value = ShareableElementData::createWithAttributes(attributes);
-
- return it->value.get();
+ if (!elementData)
+ elementData = m_shareableElementDataCache.set(attributeHash(attributes), ShareableElementData::createWithAttributes(attributes)).storedValue->value.get();
esprehn 2014/05/14 20:25:27 You make us do two hash lookups now instead of one
wibling-chromium 2014/05/15 13:15:18 The reason is that the createWithAttributes call m
+ ASSERT(elementData);
+ return elementData;
}
ElementDataCache::ElementDataCache()

Powered by Google App Engine
This is Rietveld 408576698