Replace all uses of Enum.empty? with the dedicated empty? functions

This commit is contained in:
Marcel Otto 2022-04-05 22:07:38 +02:00
parent bf158d90ae
commit 9e62b23a77
6 changed files with 10 additions and 10 deletions

View file

@ -319,7 +319,7 @@ defmodule RDF.Dataset do
%__MODULE__{
dataset
| graphs:
if Enum.empty?(new_graph) do
if Graph.empty?(new_graph) do
Map.delete(dataset.graphs, graph_name)
else
Map.put(dataset.graphs, graph_name, new_graph)
@ -475,7 +475,7 @@ defmodule RDF.Dataset do
{{s, p, o}, popped_graph} = Graph.pop(graph)
popped =
if Enum.empty?(popped_graph),
if Graph.empty?(popped_graph),
do: graphs |> Map.delete(graph_name),
else: graphs |> Map.put(graph_name, popped_graph)

View file

@ -33,7 +33,7 @@ defmodule RDF.Diff do
defp coerce_graph(nil), do: Graph.new()
defp coerce_graph(%Description{} = description),
do: if(Enum.empty?(description), do: Graph.new(), else: Graph.new(description))
do: if(Description.empty?(description), do: Graph.new(), else: Graph.new(description))
defp coerce_graph(data), do: Graph.new(init: data)

View file

@ -196,7 +196,7 @@ defmodule RDF.Graph do
def add(graph, input, opts \\ [])
def add(%__MODULE__{descriptions: descriptions} = graph, %Description{} = description, opts) do
if Enum.empty?(description) do
if Description.empty?(description) do
graph
else
%__MODULE__{
@ -430,7 +430,7 @@ defmodule RDF.Graph do
%__MODULE__{
graph
| descriptions:
if Enum.empty?(new_description) do
if Description.empty?(new_description) do
Map.delete(descriptions, subject)
else
Map.put(descriptions, subject, new_description)
@ -739,7 +739,7 @@ defmodule RDF.Graph do
{triple, popped_description} = Description.pop(description)
popped =
if Enum.empty?(popped_description),
if Description.empty?(popped_description),
do: descriptions |> Map.delete(subject),
else: descriptions |> Map.put(subject, popped_description)

View file

@ -32,7 +32,7 @@ defimpl Inspect, for: RDF.Description do
header = "#RDF.Description<subject: #{inspect(description.subject)}"
if Enum.empty?(description) do
if RDF.Description.empty?(description) do
header <> ">"
else
body =

View file

@ -253,7 +253,7 @@ defmodule RDF.Turtle.Encoder do
defp blank_node_property_list(description, state, nesting) do
indented = nesting + @indentation
if Enum.empty?(description) do
if Description.empty?(description) do
"[]"
else
"[" <>
@ -348,7 +348,7 @@ defmodule RDF.Turtle.Encoder do
defp list_subject_description(description) do
description = Description.delete_predicates(description, [RDF.first(), RDF.rest()])
if Enum.count(description.predications) == 0 do
if Description.empty?(description) do
# since the Turtle grammar doesn't allow bare lists, we add a statement
description |> RDF.type(RDF.List)
else

View file

@ -73,7 +73,7 @@ defmodule RDF.Star.Graph do
description_without_quoted_triples =
Description.without_quoted_triple_objects(description)
if Enum.empty?(description_without_quoted_triples) do
if Description.empty?(description_without_quoted_triples) do
Map.delete(descriptions, subject)
else
Map.put(descriptions, subject, description_without_quoted_triples)