Changeset 268852 in webkit
- Timestamp:
- Oct 21, 2020, 9:50:33 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
bindings/js/JSDOMConvertRecord.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268850 r268852 1 2020-10-21 Alex Christensen <achristensen@webkit.org> 2 3 Replace O(n^2) algorithm from r268709 with O(n) algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=218062 5 6 Reviewed by Alexey Shvayka. 7 8 r268709 introduced a Vector::findMatching call inside a loop that populates the Vector. 9 This causes very slow construction of URLSearchParams with large dictionaries with 16-bit keys. 10 To speed things up, keep a HashMap of the 16-bit strings we have already inserted to their index in the Vector 11 so we don't need to search the Vector. 12 13 * bindings/js/JSDOMConvertRecord.h: 14 1 15 2020-10-21 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 16 -
trunk/Source/WebCore/bindings/js/JSDOMConvertRecord.h
r268709 r268852 97 97 98 98 ReturnType result; 99 HashMap<KeyType, size_t> resultMap; 99 100 100 101 // 4. Let keys be ? O.[[OwnPropertyKeys]](). … … 132 133 if constexpr (std::is_same_v<K, IDLUSVString>) { 133 134 if (!typedKey.is8Bit()) { 134 auto index = result.findMatching([&](auto& entry) { return entry.key == typedKey; }); 135 if (index != notFound) { 136 result[index].value = typedValue; 135 auto iterator = resultMap.find(typedKey); 136 if (iterator != resultMap.end()) { 137 ASSERT(result[iterator->value].key == typedKey); 138 result[iterator->value].value = WTFMove(typedValue); 137 139 continue; 138 140 } 141 resultMap.add(typedKey, result.size()); 139 142 } 140 } 143 } else 144 UNUSED_VARIABLE(resultMap); 141 145 142 result.append({ typedKey, typedValue }); 146 // 5. Otherwise, append to result a mapping (typedKey, typedValue). 147 result.append({ WTFMove(typedKey), WTFMove(typedValue) }); 143 148 } 144 149 }
Note:
See TracChangeset
for help on using the changeset viewer.