-
kling@webkit.org authored
<http://webkit.org/b/94990> Reviewed by Antti Koivisto. Keep a cache of ElementAttributeData objects for a given set of attributes and reuse them in elements with identical attribute maps. ElementAttributeData is made ref-counted to facilitate this. A copy-on-write mechanism is already in place, since mutating call sites have to go via Element::mutableAttributeData(). The cache is held by Document and cleared in Document::finishedParsing() since the vast majority of immutable ElementAttributeData will be constructed during parsing. On the HTML5 spec at <http://whatwg.org/c/>, we get a cache hit rate of nearly 80%, translating into a 3.5MB reduction in memory use. * dom/Document.cpp: (WebCore::Document::finishedParsing): (ImmutableAttributeDataCacheKey): (WebCore::ImmutableAttributeDataCacheKey::ImmutableAttributeDataCacheKey): (WebCore::ImmutableAttributeDataCacheKey::operator!=): (WebCore::ImmutableAttributeDataCacheKey::hash): (ImmutableAttributeDataCacheEntry): (WebCore::Document::cachedImmutableAttributeData): * dom/Document.h: * dom/Element.cpp: (WebCore::Element::parserSetAttributes): * dom/Element.h: * dom/ElementAttributeData.cpp: (WebCore::ElementAttributeData::createImmutable): (WebCore::ElementAttributeData::ElementAttributeData): * dom/ElementAttributeData.h: (WebCore::ElementAttributeData::create): (ElementAttributeData): (WebCore::ElementAttributeData::makeMutable): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
7c575786