From b903553aaf04b2636290704021b00d9c546a62b3 Mon Sep 17 00:00:00 2001 From: Sam O'Connor Date: Thu, 19 Jul 2018 12:01:34 +1000 Subject: [PATCH] DataStructures 0.10.0 is not available yet --- REQUIRE | 2 +- src/XMLDict.jl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/REQUIRE b/REQUIRE index c9b89b3..fe94d8f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.7-DEV.1393 Compat 0.60.0 EzXML -DataStructures 0.10.0 +DataStructures IterTools diff --git a/src/XMLDict.jl b/src/XMLDict.jl index 9cc7cb8..ef383af 100644 --- a/src/XMLDict.jl +++ b/src/XMLDict.jl @@ -252,8 +252,11 @@ function dict_xml(root::AbstractDict) string("\n", node_xml(root)) end -attrs(node::AbstractDict) = filter(pair->isa(first(pair), Symbol), node) -nodes(node::AbstractDict) = filter(pair->!isa(first(pair), Symbol), node) +# FIXME: We can go back to using filter instead of filter! once +# https://github.com/JuliaCollections/DataStructures.jl/issues/400 is fixed. +# Calling filter! with copy is equivalent but inefficient. +attrs(node::AbstractDict) = filter!(pair->isa(first(pair), Symbol), copy(node)) +nodes(node::AbstractDict) = filter!(pair->!isa(first(pair), Symbol), copy(n function attr_xml(node::AbstractDict) join([" $n=\"$v\"" for (n,v) in attrs(node)])