⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 175602 in webkit


Ignore:
Timestamp:
Nov 4, 2014, 7:58:19 PM (12 years ago)
Author:
Chris Dumez
Message:

Avoid double hash table lookup in SpaceSplitStringData::create()
https://bugs.webkit.org/show_bug.cgi?id=138396

Reviewed by Ryosuke Niwa.

Avoid double hash table lookup in SpaceSplitStringData::create() by
calling HashMap::add() and using the AddResult, instead of calling
HashMap::get() then HashMap::add().

No new tests, no behavior change.

  • dom/SpaceSplitString.cpp:

(WebCore::SpaceSplitStringData::create):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175601 r175602  
     12014-11-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Avoid double hash table lookup in SpaceSplitStringData::create()
     4        https://bugs.webkit.org/show_bug.cgi?id=138396
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Avoid double hash table lookup in SpaceSplitStringData::create() by
     9        calling HashMap::add() and using the AddResult, instead of calling
     10        HashMap::get() then HashMap::add().
     11
     12        No new tests, no behavior change.
     13
     14        * dom/SpaceSplitString.cpp:
     15        (WebCore::SpaceSplitStringData::create):
     16
    1172014-11-04  Zalan Bujtas  <zalan@apple.com>
    218
  • trunk/Source/WebCore/dom/SpaceSplitString.cpp

    r175028 r175602  
    197197    ASSERT(!keyString.isNull());
    198198
    199     auto& table = spaceSplitStringTable();
    200     if (SpaceSplitStringData* data = table.get(keyString))
    201         return data;
     199    auto addResult = spaceSplitStringTable().add(keyString, nullptr);
     200    if (!addResult.isNewEntry)
     201        return addResult.iterator->value;
    202202
    203203    // Nothing in the cache? Let's create a new SpaceSplitStringData if the input has something useful.
     
    211211
    212212    RefPtr<SpaceSplitStringData> spaceSplitStringData = create(keyString, tokenCount);
    213     table.add(keyString, spaceSplitStringData.get());
     213    addResult.iterator->value = spaceSplitStringData.get();
    214214    return spaceSplitStringData.release();
    215215}
Note: See TracChangeset for help on using the changeset viewer.