+2013-12-19 Andreas Kling <akling@apple.com>
+
+ Two small refinements to matched properties cache.
+ <https://webkit.org/b/125992>
+
+ - Avoid computing the matched properties hash if we're banned from
+ using the cache anyway.
+
+ - When adding a new entry to the cache, use move semantics to avoid
+ creating a transient copy of all the data.
+
+ Reviewed by Antti Koivisto.
+
2013-12-19 Andreas Kling <akling@apple.com>
CascadedProperties should use a bitset to track property presence.
// The RenderStyle in the cache is really just a holder for the substructures and never used as-is.
cacheItem.renderStyle = RenderStyle::clone(style);
cacheItem.parentRenderStyle = RenderStyle::clone(parentStyle);
- m_matchedPropertiesCache.add(hash, cacheItem);
+ m_matchedPropertiesCache.add(hash, std::move(cacheItem));
}
void StyleResolver::invalidateMatchedPropertiesCache()
{
ASSERT(element);
State& state = m_state;
- unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
+ unsigned cacheHash = shouldUseMatchedPropertiesCache && matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
bool applyInheritedOnly = false;
const MatchedPropertiesCacheItem* cacheItem = 0;
- if (shouldUseMatchedPropertiesCache && cacheHash && (cacheItem = findFromMatchedPropertiesCache(cacheHash, matchResult))) {
+ if (cacheHash && (cacheItem = findFromMatchedPropertiesCache(cacheHash, matchResult))) {
// We can build up the style by copying non-inherited properties from an earlier style object built using the same exact
// style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the
// element context. This is fast and saves memory by reusing the style data structures.