Title: [114558] trunk/Source/WebCore
- Revision
- 114558
- Author
- [email protected]
- Date
- 2012-04-18 14:01:56 -0700 (Wed, 18 Apr 2012)
Log Message
CSSValuePool: Make numeric value caches fixed-size arrays.
<http://webkit.org/b/84268>
Reviewed by Antti Koivisto.
Change the numeric CSSPrimitiveValue caches in CSSValuePool from HashMaps to
fixed-size arrays of RefPtr<CSSPrimitiveValue>s.
This is more space efficient and doesn't incur the cost of a hash lookup every
time a numeric CSSPrimitiveValue is needed. We retain the limit of caching
only values between 0-255 for now.
* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::CSSValuePool):
(WebCore::CSSValuePool::createValue):
* css/CSSValuePool.h:
(CSSValuePool):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (114557 => 114558)
--- trunk/Source/WebCore/ChangeLog 2012-04-18 20:53:44 UTC (rev 114557)
+++ trunk/Source/WebCore/ChangeLog 2012-04-18 21:01:56 UTC (rev 114558)
@@ -1,3 +1,23 @@
+2012-04-18 Andreas Kling <[email protected]>
+
+ CSSValuePool: Make numeric value caches fixed-size arrays.
+ <http://webkit.org/b/84268>
+
+ Reviewed by Antti Koivisto.
+
+ Change the numeric CSSPrimitiveValue caches in CSSValuePool from HashMaps to
+ fixed-size arrays of RefPtr<CSSPrimitiveValue>s.
+
+ This is more space efficient and doesn't incur the cost of a hash lookup every
+ time a numeric CSSPrimitiveValue is needed. We retain the limit of caching
+ only values between 0-255 for now.
+
+ * css/CSSValuePool.cpp:
+ (WebCore::CSSValuePool::CSSValuePool):
+ (WebCore::CSSValuePool::createValue):
+ * css/CSSValuePool.h:
+ (CSSValuePool):
+
2012-04-18 Dana Jansens <[email protected]>
[chromium] Rename overdraw histograms so we can use field trials in histograms.xml
Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (114557 => 114558)
--- trunk/Source/WebCore/css/CSSValuePool.cpp 2012-04-18 20:53:44 UTC (rev 114557)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp 2012-04-18 21:01:56 UTC (rev 114558)
@@ -46,9 +46,6 @@
, m_colorTransparent(CSSPrimitiveValue::createColor(Color::transparent))
, m_colorWhite(CSSPrimitiveValue::createColor(Color::white))
, m_colorBlack(CSSPrimitiveValue::createColor(Color::black))
- , m_pixelZero(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX))
- , m_percentZero(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PERCENTAGE))
- , m_numberZero(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_NUMBER))
{
}
@@ -87,41 +84,31 @@
PassRefPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimitiveValue::UnitTypes type)
{
- // Small positive integers repeat often.
- static const int maximumCacheableValue = 256;
- if (value < 0 || value > maximumCacheableValue)
+ if (value < 0 || value > maximumCacheableIntegerValue)
return CSSPrimitiveValue::create(value, type);
int intValue = static_cast<int>(value);
if (value != intValue)
return CSSPrimitiveValue::create(value, type);
- IntegerValueCache* cache;
+ RefPtr<CSSPrimitiveValue>* cache;
switch (type) {
case CSSPrimitiveValue::CSS_PX:
- if (intValue == 0)
- return m_pixelZero;
- cache = &m_pixelValueCache;
+ cache = m_pixelValueCache;
break;
case CSSPrimitiveValue::CSS_PERCENTAGE:
- if (intValue == 0)
- return m_percentZero;
- cache = &m_percentValueCache;
+ cache = m_percentValueCache;
break;
case CSSPrimitiveValue::CSS_NUMBER:
- if (intValue == 0)
- return m_numberZero;
- cache = &m_numberValueCache;
+ cache = m_numberValueCache;
break;
default:
return CSSPrimitiveValue::create(value, type);
}
- RefPtr<CSSPrimitiveValue> dummyValue;
- IntegerValueCache::AddResult entry = cache->add(intValue, dummyValue);
- if (entry.isNewEntry)
- entry.iterator->second = CSSPrimitiveValue::create(value, type);
- return entry.iterator->second;
+ if (!cache[intValue])
+ cache[intValue] = CSSPrimitiveValue::create(value, type);
+ return cache[intValue];
}
PassRefPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName)
Modified: trunk/Source/WebCore/css/CSSValuePool.h (114557 => 114558)
--- trunk/Source/WebCore/css/CSSValuePool.h 2012-04-18 20:53:44 UTC (rev 114557)
+++ trunk/Source/WebCore/css/CSSValuePool.h 2012-04-18 21:01:56 UTC (rev 114558)
@@ -66,14 +66,12 @@
RefPtr<CSSPrimitiveValue> m_colorWhite;
RefPtr<CSSPrimitiveValue> m_colorBlack;
- typedef HashMap<int, RefPtr<CSSPrimitiveValue> > IntegerValueCache;
- RefPtr<CSSPrimitiveValue> m_pixelZero;
- RefPtr<CSSPrimitiveValue> m_percentZero;
- RefPtr<CSSPrimitiveValue> m_numberZero;
- IntegerValueCache m_pixelValueCache;
- IntegerValueCache m_percentValueCache;
- IntegerValueCache m_numberValueCache;
+ static const int maximumCacheableIntegerValue = 255;
+ RefPtr<CSSPrimitiveValue> m_pixelValueCache[maximumCacheableIntegerValue + 1];
+ RefPtr<CSSPrimitiveValue> m_percentValueCache[maximumCacheableIntegerValue + 1];
+ RefPtr<CSSPrimitiveValue> m_numberValueCache[maximumCacheableIntegerValue + 1];
+
typedef HashMap<AtomicString, RefPtr<CSSValueList> > FontFaceValueCache;
FontFaceValueCache m_fontFaceValueCache;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes