Optimize RDF.PrefixMap.new/1 creation from another PrefixMap
This commit is contained in:
parent
6c9f580cab
commit
c2e6ffdebb
2 changed files with 6 additions and 0 deletions
|
@ -23,6 +23,8 @@ defmodule RDF.PrefixMap do
|
||||||
"""
|
"""
|
||||||
def new(map)
|
def new(map)
|
||||||
|
|
||||||
|
def new(%__MODULE__{} = prefix_map), do: prefix_map
|
||||||
|
|
||||||
def new(map) when is_map(map) do
|
def new(map) when is_map(map) do
|
||||||
%__MODULE__{map: Map.new(map, &normalize/1)}
|
%__MODULE__{map: Map.new(map, &normalize/1)}
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,6 +45,10 @@ defmodule RDF.PrefixMapTest do
|
||||||
) == @example2
|
) == @example2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "with another prefix map" do
|
||||||
|
assert PrefixMap.new(@example2) == @example2
|
||||||
|
end
|
||||||
|
|
||||||
test "when the IRI namespace is given as a RDF.Vocabulary.Namespace" do
|
test "when the IRI namespace is given as a RDF.Vocabulary.Namespace" do
|
||||||
assert PrefixMap.new(
|
assert PrefixMap.new(
|
||||||
ex1: "http://example.com/foo/",
|
ex1: "http://example.com/foo/",
|
||||||
|
|
Loading…
Reference in a new issue