File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -201,15 +201,13 @@ class XmlBuilder {
201
201
if (optimizeNamespaces) {
202
202
// Remove unused namespaces: The reason we first add them and then remove
203
203
// them again is to keep the order in which they have been added.
204
- element.namespaces.forEach ((uri, meta) {
205
- if (! meta.used) {
206
- final qualified = meta.name.qualified;
207
- final attribute = element.attributes.firstWhere (
208
- (attribute) => attribute.name.qualified == qualified,
209
- );
210
- element.attributes.remove (attribute);
211
- }
212
- });
204
+ final toRemove = element.namespaces.values
205
+ .where ((meta) => ! meta.used)
206
+ .map ((meta) => meta.name.qualified)
207
+ .toSet ();
208
+ element.attributes.removeWhere (
209
+ (attribute) => toRemove.contains (attribute.name.qualified),
210
+ );
213
211
}
214
212
} finally {
215
213
_stack.removeLast ();
You can’t perform that action at this time.
0 commit comments