Ref<ShareableElementData> DocumentSharedObjectPool::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
{
    ASSERT(!attributes.isEmpty());

    auto& cachedData = m_shareableElementDataCache.add(attributeHash(attributes), nullptr).iterator->value;

    // FIXME: This prevents sharing when there's a hash collision.
    if (cachedData && !hasSameAttributes(attributes, *cachedData))
        return ShareableElementData::createWithAttributes(attributes);

    if (!cachedData)
        cachedData = ShareableElementData::createWithAttributes(attributes);

    return *cachedData;
}
示例#2
0
PassRefPtrWillBeRawPtr<ShareableElementData> ElementDataCache::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
{
    ASSERT(!attributes.isEmpty());

    ShareableElementDataCache::ValueType* it = m_shareableElementDataCache.add(attributeHash(attributes), nullptr).storedValue;

    // FIXME: This prevents sharing when there's a hash collision.
    if (it->value && !hasSameAttributes(attributes, *it->value))
        return ShareableElementData::createWithAttributes(attributes);

    if (!it->value)
        it->value = ShareableElementData::createWithAttributes(attributes);

    return it->value.get();
}