Skip to content

Commit 73967ee

Browse files
committed
Everywhere: Use HashMap::update() where applicable
1 parent 0b96690 commit 73967ee

File tree

7 files changed

+13
-31
lines changed

7 files changed

+13
-31
lines changed

Libraries/LibIDL/IDLParser.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,7 @@ Interface& Parser::parse()
12021202
interface.extend_with_partial_interface(*partial_interface);
12031203
}
12041204

1205-
for (auto& dictionary : import.dictionaries)
1206-
interface.dictionaries.set(dictionary.key, dictionary.value);
1205+
interface.dictionaries.update(import.dictionaries);
12071206

12081207
for (auto& partial_dictionary : import.partial_dictionaries) {
12091208
auto& it = interface.partial_dictionaries.ensure(partial_dictionary.key);
@@ -1216,17 +1215,15 @@ Interface& Parser::parse()
12161215
interface.enumerations.set(enumeration.key, move(enumeration_copy));
12171216
}
12181217

1219-
for (auto& typedef_ : import.typedefs)
1220-
interface.typedefs.set(typedef_.key, typedef_.value);
1218+
interface.typedefs.update(import.typedefs);
12211219

12221220
for (auto& mixin : import.mixins) {
12231221
if (auto it = interface.mixins.find(mixin.key); it != interface.mixins.end() && it->value != mixin.value)
12241222
report_parsing_error(ByteString::formatted("Mixin '{}' was already defined in {}", mixin.key, mixin.value->module_own_path), filename, input, lexer.tell());
12251223
interface.mixins.set(mixin.key, mixin.value);
12261224
}
12271225

1228-
for (auto& callback_function : import.callback_functions)
1229-
interface.callback_functions.set(callback_function.key, callback_function.value);
1226+
interface.callback_functions.update(import.callback_functions);
12301227
}
12311228

12321229
// Resolve mixins

Libraries/LibIDL/Types.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,35 +309,27 @@ void Interface::extend_with_partial_interface(Interface const& partial)
309309
{
310310
for (auto const& attribute : partial.attributes) {
311311
auto attribute_copy = attribute;
312-
for (auto const& [key, value] : partial.extended_attributes) {
313-
attribute_copy.extended_attributes.set(key, value);
314-
}
312+
attribute_copy.extended_attributes.update(partial.extended_attributes);
315313
attributes.append(move(attribute_copy));
316314
}
317315

318316
for (auto const& static_attribute : partial.static_attributes) {
319317
auto static_attribute_copy = static_attribute;
320-
for (auto const& [key, value] : partial.extended_attributes) {
321-
static_attribute_copy.extended_attributes.set(key, value);
322-
}
318+
static_attribute_copy.extended_attributes.update(partial.extended_attributes);
323319
static_attributes.append(move(static_attribute_copy));
324320
}
325321

326322
constants.extend(partial.constants);
327323

328324
for (auto const& function : partial.functions) {
329325
auto function_copy = function;
330-
for (auto const& [key, value] : partial.extended_attributes) {
331-
function_copy.extended_attributes.set(key, value);
332-
}
326+
function_copy.extended_attributes.update(partial.extended_attributes);
333327
functions.append(move(function_copy));
334328
}
335329

336330
for (auto const& static_function : partial.static_functions) {
337331
auto static_function_copy = static_function;
338-
for (auto const& [key, value] : partial.extended_attributes) {
339-
static_function_copy.extended_attributes.set(key, value);
340-
}
332+
static_function_copy.extended_attributes.update(partial.extended_attributes);
341333
static_functions.append(move(static_function_copy));
342334
}
343335
}

Libraries/LibRegex/RegexByteCode.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ class REGEX_API ByteCode : public DisjointChunks<ByteCodeValueType> {
278278
}
279279
m_string_table.m_table.set(entry.key, entry.value);
280280
}
281-
for (auto const& entry : other.m_string_table.m_inverse_table)
282-
m_string_table.m_inverse_table.set(entry.key, entry.value);
281+
m_string_table.m_inverse_table.update(other.m_string_table.m_inverse_table);
283282
}
284283
}
285284

Libraries/LibWeb/Animations/KeyframeEffect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ static WebIDL::ExceptionOr<Vector<BaseKeyframe>> process_a_keyframes_argument(JS
416416
if (keyframe_a.computed_offset.value() == keyframe_b.computed_offset.value()) {
417417
keyframe_a.easing = keyframe_b.easing;
418418
keyframe_a.composite = keyframe_b.composite;
419-
for (auto const& [property_name, property_value] : keyframe_b.unparsed_properties())
420-
keyframe_a.unparsed_properties().set(property_name, property_value);
419+
keyframe_a.unparsed_properties().update(keyframe_b.unparsed_properties());
421420
processed_keyframes.remove(i + 1);
422421
i--;
423422
}

Libraries/LibWeb/CSS/StyleComputer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,8 @@ static void cascade_custom_properties(DOM::Element& element, Optional<CSS::Pseud
983983
}
984984

985985
if (!pseudo_element.has_value()) {
986-
if (auto const inline_style = element.inline_style()) {
987-
for (auto const& it : inline_style->custom_properties())
988-
custom_properties.set(it.key, it.value);
989-
}
986+
if (auto const inline_style = element.inline_style())
987+
custom_properties.update(inline_style->custom_properties());
990988
}
991989
}
992990

Libraries/LibWeb/HTML/XMLSerializer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ static WebIDL::ExceptionOr<String> serialize_element(DOM::Element const& element
515515
// To copy a namespace prefix map map means to copy the map's keys into a new empty namespace prefix map,
516516
// and to copy each of the values in the namespace prefix list associated with each keys' value into a new list
517517
// which should be associated with the respective key in the new map.
518-
for (auto const& map_entry : namespace_prefix_map)
519-
map.set(map_entry.key, map_entry.value);
518+
map.update(namespace_prefix_map);
520519

521520
// 7. Let local prefixes map be an empty map. The map has unique Node prefix strings as its keys, with corresponding namespaceURI Node values
522521
// as the map's key values (in this map, the null namespace is represented by the empty string).

Libraries/LibWeb/Layout/InlineLevelIterator.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,7 @@ Gfx::ShapeFeatures InlineLevelIterator::create_and_merge_font_features() const
461461
// FIXME 2. If the font is defined via an @font-face rule, the font features implied by the font-feature-settings descriptor in the @font-face rule.
462462

463463
// 3. Font features implied by the value of the ‘font-variant’ property, the related ‘font-variant’ subproperties and any other CSS property that uses OpenType features (e.g. the ‘font-kerning’ property).
464-
for (auto& it : shape_features_map()) {
465-
merged_features.set(it.key, it.value);
466-
}
464+
merged_features.update(shape_features_map());
467465

468466
// FIXME 4. Feature settings determined by properties other than ‘font-variant’ or ‘font-feature-settings’. For example, setting a non-default value for the ‘letter-spacing’ property disables common ligatures.
469467

0 commit comments

Comments
 (0)