Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/elixir/lib/kernel/parallel_compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ defmodule Kernel.ParallelCompiler do
# i.e. to find code that depends on code that we know is not being defined.
# Note that not all files have been compiled yet, so they may not be in waiting.
defp without_definition(waiting, files) do
nillify_empty(
nilify_empty(
for %{pid: pid} <- files,
{_, _, ref, ^pid, on, _, _} <- waiting,
not defining?(on, waiting),
Expand All @@ -505,7 +505,7 @@ defmodule Kernel.ParallelCompiler do
end

defp deadlocked(waiting, type, defining?) do
nillify_empty(
nilify_empty(
for {_, _, ref, _, on, _, ^type} <- waiting,
defining?(on, waiting) == defining?,
do: {ref, :deadlock}
Expand All @@ -516,8 +516,8 @@ defmodule Kernel.ParallelCompiler do
Enum.any?(waiting, fn {_, _, _, _, _, defining, _} -> on in defining end)
end

defp nillify_empty([]), do: nil
defp nillify_empty([_ | _] = list), do: list
defp nilify_empty([]), do: nil
defp nilify_empty([_ | _] = list), do: list

# Wait for messages from child processes
defp wait_for_messages(queue, spawned, waiting, files, result, warnings, state) do
Expand Down
10 changes: 5 additions & 5 deletions lib/elixir/lib/port.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ defmodule Port do
"""
@spec info(port) :: keyword | nil
def info(port) do
nillify(:erlang.port_info(port))
nilify(:erlang.port_info(port))
end

@doc """
Expand All @@ -270,7 +270,7 @@ defmodule Port do
end

def info(port, item) do
nillify(:erlang.port_info(port, item))
nilify(:erlang.port_info(port, item))
end

@doc """
Expand Down Expand Up @@ -323,7 +323,7 @@ defmodule Port do
:erlang.ports()
end

@compile {:inline, nillify: 1}
defp nillify(:undefined), do: nil
defp nillify(other), do: other
@compile {:inline, nilify: 1}
defp nilify(:undefined), do: nil
defp nilify(other), do: other
end
16 changes: 8 additions & 8 deletions lib/elixir/lib/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defmodule Process do
"""
@spec put(term, term) :: term | nil
def put(key, value) do
nillify(:erlang.put(key, value))
nilify(:erlang.put(key, value))
end

@doc """
Expand All @@ -136,7 +136,7 @@ defmodule Process do
"""
@spec delete(term) :: term | nil
def delete(key) do
nillify(:erlang.erase(key))
nilify(:erlang.erase(key))
end

@doc """
Expand Down Expand Up @@ -650,7 +650,7 @@ defmodule Process do
"""
@spec whereis(atom) :: pid | port | nil
def whereis(name) do
nillify(:erlang.whereis(name))
nilify(:erlang.whereis(name))
end

@doc """
Expand Down Expand Up @@ -749,7 +749,7 @@ defmodule Process do
"""
@spec info(pid) :: keyword | nil
def info(pid) do
nillify(:erlang.process_info(pid))
nilify(:erlang.process_info(pid))
end

@doc """
Expand All @@ -770,7 +770,7 @@ defmodule Process do
end

def info(pid, spec) when is_atom(spec) or is_list(spec) do
nillify(:erlang.process_info(pid, spec))
nilify(:erlang.process_info(pid, spec))
end

@doc """
Expand All @@ -788,7 +788,7 @@ defmodule Process do
@spec hibernate(module, atom, list) :: no_return
defdelegate hibernate(mod, fun_name, args), to: :erlang

@compile {:inline, nillify: 1}
defp nillify(:undefined), do: nil
defp nillify(other), do: other
@compile {:inline, nilify: 1}
defp nilify(:undefined), do: nil
defp nilify(other), do: other
end
20 changes: 10 additions & 10 deletions lib/elixir/lib/uri.ex
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,9 @@ defmodule URI do
],
parts

path = nillify(path)
scheme = nillify(scheme)
query = nillify_query(query_with_question_mark)
path = nilify(path)
scheme = nilify(scheme)
query = nilify_query(query_with_question_mark)
{authority, userinfo, host, port} = split_authority(authority_with_slashes)

scheme = scheme && String.downcase(scheme)
Expand All @@ -814,8 +814,8 @@ defmodule URI do
}
end

defp nillify_query("?" <> query), do: query
defp nillify_query(_other), do: nil
defp nilify_query("?" <> query), do: query
defp nilify_query(_other), do: nil

# Split an authority into its userinfo, host and port parts.
#
Expand All @@ -834,17 +834,17 @@ defmodule URI do
components = Regex.run(regex, authority)

destructure [_, _, userinfo, host, _, port], components
userinfo = nillify(userinfo)
host = if nillify(host), do: host |> String.trim_leading("[") |> String.trim_trailing("]")
port = if nillify(port), do: String.to_integer(port)
userinfo = nilify(userinfo)
host = if nilify(host), do: host |> String.trim_leading("[") |> String.trim_trailing("]")
port = if nilify(port), do: String.to_integer(port)

{authority, userinfo, host, port}
end

# Regex.run returns empty strings sometimes. We want
# to replace those with nil for consistency.
defp nillify(""), do: nil
defp nillify(other), do: other
defp nilify(""), do: nil
defp nilify(other), do: other

@doc """
Returns the string representation of the given [URI struct](`t:t/0`).
Expand Down