Optimize canonical_lexical/1 implementation on RDF.XSD.Datatypes
This commit is contained in:
parent
1b213d3d80
commit
8106f89ca0
3 changed files with 7 additions and 1 deletions
|
@ -401,6 +401,7 @@ defmodule RDF.Literal.Datatype do
|
|||
|
||||
defoverridable datatype_id: 1,
|
||||
language: 1,
|
||||
canonical_lexical: 1,
|
||||
cast: 1,
|
||||
do_cast: 1,
|
||||
equal_value?: 2,
|
||||
|
|
|
@ -298,7 +298,7 @@ defmodule RDF.Turtle.Encoder do
|
|||
defp term(%Literal{literal: %datatype{}} = literal, state, _, nesting)
|
||||
when datatype in @native_supported_datatypes do
|
||||
if Literal.valid?(literal) do
|
||||
literal |> Literal.canonical() |> Literal.lexical()
|
||||
Literal.canonical_lexical(literal)
|
||||
else
|
||||
typed_literal_term(literal, state, nesting)
|
||||
end
|
||||
|
|
|
@ -225,6 +225,11 @@ defmodule RDF.XSD.Datatype do
|
|||
|
||||
def lexical(%__MODULE__{uncanonical_lexical: lexical}), do: lexical
|
||||
|
||||
@impl RDF.Literal.Datatype
|
||||
def canonical_lexical(%RDF.Literal{literal: literal}), do: canonical_lexical(literal)
|
||||
def canonical_lexical(%__MODULE__{value: value}) when not is_nil(value), do: canonical_mapping(value)
|
||||
def canonical_lexical(_), do: nil
|
||||
|
||||
@impl RDF.Literal.Datatype
|
||||
def canonical(literal)
|
||||
|
||||
|
|
Loading…
Reference in a new issue