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

Side by Side Diff: third_party/WebKit/Source/core/dom/ElementDataCache.cpp

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return !memcmp(attributes.data(), elementData.m_attributeArray, 42 return !memcmp(attributes.data(), elementData.m_attributeArray,
43 attributes.size() * sizeof(Attribute)); 43 attributes.size() * sizeof(Attribute));
44 } 44 }
45 45
46 ShareableElementData* 46 ShareableElementData*
47 ElementDataCache::cachedShareableElementDataWithAttributes( 47 ElementDataCache::cachedShareableElementDataWithAttributes(
48 const Vector<Attribute>& attributes) { 48 const Vector<Attribute>& attributes) {
49 DCHECK(!attributes.isEmpty()); 49 DCHECK(!attributes.isEmpty());
50 50
51 ShareableElementDataCache::ValueType* it = 51 ShareableElementDataCache::ValueType* it =
52 m_shareableElementDataCache.add(attributeHash(attributes), nullptr) 52 m_shareableElementDataCache.insert(attributeHash(attributes), nullptr)
53 .storedValue; 53 .storedValue;
54 54
55 // FIXME: This prevents sharing when there's a hash collision. 55 // FIXME: This prevents sharing when there's a hash collision.
56 if (it->value && !hasSameAttributes(attributes, *it->value)) 56 if (it->value && !hasSameAttributes(attributes, *it->value))
57 return ShareableElementData::createWithAttributes(attributes); 57 return ShareableElementData::createWithAttributes(attributes);
58 58
59 if (!it->value) 59 if (!it->value)
60 it->value = ShareableElementData::createWithAttributes(attributes); 60 it->value = ShareableElementData::createWithAttributes(attributes);
61 61
62 return it->value.get(); 62 return it->value.get();
63 } 63 }
64 64
65 ElementDataCache::ElementDataCache() {} 65 ElementDataCache::ElementDataCache() {}
66 66
67 DEFINE_TRACE(ElementDataCache) { 67 DEFINE_TRACE(ElementDataCache) {
68 visitor->trace(m_shareableElementDataCache); 68 visitor->trace(m_shareableElementDataCache);
69 } 69 }
70 70
71 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698