Skip to content

Commit 867e58c

Browse files
committed
Refactor bulk collection operations
1 parent 8a87d5b commit 867e58c

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

commonmark-ext-image-attributes/src/main/java/org/commonmark/ext/image/attributes/internal/ImageAttributesAttributeProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public void setAttributes(Node node, String tagName, final Map<String, String> a
2626
public void visit(CustomNode node) {
2727
if (node instanceof ImageAttributes) {
2828
ImageAttributes imageAttributes = (ImageAttributes) node;
29-
for (Map.Entry<String, String> entry : imageAttributes.getAttributes().entrySet()) {
30-
attributes.put(entry.getKey(), entry.getValue());
31-
}
29+
attributes.putAll(imageAttributes.getAttributes());
3230
// Now that we have used the image attributes we remove the node.
3331
imageAttributes.unlink();
3432
}

commonmark/src/main/java/org/commonmark/internal/DocumentParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ public static Set<Class<? extends Block>> getDefaultBlockParserTypes() {
105105
}
106106

107107
public static List<BlockParserFactory> calculateBlockParserFactories(List<BlockParserFactory> customBlockParserFactories, Set<Class<? extends Block>> enabledBlockTypes) {
108-
List<BlockParserFactory> list = new ArrayList<>();
109108
// By having the custom factories come first, extensions are able to change behavior of core syntax.
110-
list.addAll(customBlockParserFactories);
109+
List<BlockParserFactory> list = new ArrayList<>(customBlockParserFactories);
111110
for (Class<? extends Block> blockType : enabledBlockTypes) {
112111
list.add(NODES_TO_CORE_FACTORIES.get(blockType));
113112
}

0 commit comments

Comments
 (0)