Skip to content

Commit

Permalink
use === for comparison to nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Aug 3, 2015
1 parent bf64cec commit b92b537
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 108 deletions.
4 changes: 2 additions & 2 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function hist_from_file(hp, file)
error(invalid_history_message, repr(line[1]), " at line ", countlines)
while !isempty(line)
m = match(r"^#\s*(\w+)\s*:\s*(.*?)\s*$", line)
m == nothing && break
m === nothing && break
if m.captures[1] == "mode"
mode = symbol(m.captures[2])
end
Expand Down Expand Up @@ -387,7 +387,7 @@ function add_history(hist::REPLHistoryProvider, s)
mode == hist.modes[end] && str == hist.history[end] && return
push!(hist.modes, mode)
push!(hist.history, str)
hist.history_file == nothing && return
hist.history_file === nothing && return
entry = """
# time: $(Libc.strftime("%Y-%m-%d %H:%M:%S %Z", time()))
# mode: $mode
Expand Down
8 changes: 4 additions & 4 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1014,23 +1014,23 @@ function (.^){T<:Number}(B::BitArray, x::T)
catch err
uerr = err
end
if zerr == nothing && uerr == nothing
if zerr === nothing && uerr === nothing
t = promote_type(typeof(z), typeof(u))
elseif zerr == nothing
elseif zerr === nothing
t = typeof(z)
else
t = typeof(u)
end
F = Array(t, size(B))
for i = 1:length(B)
if B[i]
if uerr == nothing
if uerr === nothing
F[i] = u
else
throw(uerr)
end
else
if zerr == nothing
if zerr === nothing
F[i] = z
else
throw(zerr)
Expand Down
4 changes: 2 additions & 2 deletions base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function readdlm_string(sbuff::ByteString, dlm::Char, T::Type, eol::Char, auto::

skipblanks = get(optsd, :skipblanks, true)

offset_handler = (dims == nothing) ? DLMOffsets(sbuff) : DLMStore(T, dims, has_header, sbuff, auto, eol)
offset_handler = (dims === nothing) ? DLMOffsets(sbuff) : DLMStore(T, dims, has_header, sbuff, auto, eol)

for retry in 1:2
try
Expand All @@ -259,7 +259,7 @@ function readdlm_string(sbuff::ByteString, dlm::Char, T::Type, eol::Char, auto::
else
rethrow(ex)
end
offset_handler = (dims == nothing) ? DLMOffsets(sbuff) : DLMStore(T, dims, has_header, sbuff, auto, eol)
offset_handler = (dims === nothing) ? DLMOffsets(sbuff) : DLMStore(T, dims, has_header, sbuff, auto, eol)
end
end

Expand Down
2 changes: 1 addition & 1 deletion base/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function parse(x::AbstractString,df::DateFormat)
cursor = 1
for slot in df.slots
cursor, pe = getslot(x,slot,df,cursor)
pe != nothing && push!(periods,pe)
pe !== nothing && push!(periods,pe)
cursor > endof(x) && break
end
return sort!(periods,rev=true,lt=periodisless)
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ showdict(t::Associative; kw...) = showdict(STDOUT, t; kw...)
function showdict{K,V}(io::IO, t::Associative{K,V}; limit::Bool = false, compact = false,
sz=(s = tty_size(); (s[1]-3, s[2])))
shown_set = get(task_local_storage(), :SHOWNSET, nothing)
if shown_set == nothing
if shown_set === nothing
shown_set = ObjectIdDict()
task_local_storage(:SHOWNSET, shown_set)
end
Expand Down
8 changes: 4 additions & 4 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function doc(f::Function)
for mod in modules
if haskey(meta(mod), f)
fd = meta(mod)[f]
length(docs) == 0 && fd.main != nothing && push!(docs, fd.main)
length(docs) == 0 && fd.main !== nothing && push!(docs, fd.main)
if isa(fd, FuncDoc)
for m in fd.order
push!(docs, fd.meta[m])
Expand Down Expand Up @@ -139,7 +139,7 @@ function field_meta(def)
for l in def.args[3].args
if isdoc(l)
doc = mdify(l)
elseif doc != nothing && isexpr(l, Symbol, :(::))
elseif doc !== nothing && isexpr(l, Symbol, :(::))
meta[namify(l)] = doc
doc = nothing
end
Expand Down Expand Up @@ -175,7 +175,7 @@ function doc(f::DataType)
if haskey(meta(mod), f)
fd = meta(mod)[f]
if isa(fd, TypeDoc)
length(docs) == 0 && fd.main != nothing && push!(docs, fd.main)
length(docs) == 0 && fd.main !== nothing && push!(docs, fd.main)
for m in fd.order
push!(docs, fd.meta[m])
end
Expand Down Expand Up @@ -209,7 +209,7 @@ doc(f, ::Method) = doc(f)

function doc(m::Module)
md = invoke(doc, Tuple{Any}, m)
md == nothing || return md
md === nothing || return md
readme = Pkg.dir(string(m), "README.md")
if isfile(readme)
return Markdown.parse_file(readme)
Expand Down
12 changes: 6 additions & 6 deletions base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ push!(::EnvHash, k::AbstractString, v) = setindex!(ENV, v, k)

@unix_only begin
start(::EnvHash) = 0
done(::EnvHash, i) = (ccall(:jl_environ, Any, (Int32,), i) == nothing)
done(::EnvHash, i) = (ccall(:jl_environ, Any, (Int32,), i) === nothing)

function next(::EnvHash, i)
env = ccall(:jl_environ, Any, (Int32,), i)
if env == nothing
if env === nothing
throw(BoundsError())
end
env::ByteString
m = match(r"^(.*?)=(.*)$"s, env)
if m == nothing
if m === nothing
error("malformed environment entry: $env")
end
(Pair{ByteString,ByteString}(m.captures[1], m.captures[2]), i+1)
Expand All @@ -128,7 +128,7 @@ function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
unsafe_copy!(pointer(buf), pos, len)
env = utf8(UTF16String(buf))
m = match(r"^(=?[^=]+)=(.*)$"s, env)
if m == nothing
if m === nothing
error("malformed environment entry: $env")
end
(Pair{ByteString,ByteString}(m.captures[1], m.captures[2]), (pos+len*2, blk))
Expand All @@ -155,12 +155,12 @@ function withenv{T<:AbstractString}(f::Function, keyvals::Pair{T}...)
old = Dict{T,Any}()
for (key,val) in keyvals
old[key] = get(ENV,key,nothing)
val != nothing ? (ENV[key]=val) : _unsetenv(key)
val !== nothing ? (ENV[key]=val) : _unsetenv(key)
end
try f()
finally
for (key,val) in old
val != nothing ? (ENV[key]=val) : _unsetenv(key)
val !== nothing ? (ENV[key]=val) : _unsetenv(key)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function edit(file::AbstractString, line::Integer)
issrc = length(file)>2 && file[end-2:end] == ".jl"
if issrc
f = find_source_file(file)
f != nothing && (file = f)
f !== nothing && (file = f)
end
const no_line_msg = "Unknown editor: no line number information passed.\nThe method is defined at line $line."
if startswith(edname, "emacs") || edname == "gedit"
Expand Down Expand Up @@ -293,7 +293,7 @@ function methodswith(t::Type, f::Function, showparents::Bool=false, meths = Meth
return meths
end
d = f.env.defs
while d != nothing
while d !== nothing
if any(x -> (type_close_enough(x, t) ||
(showparents ? (t <: x && (!isa(x,TypeVar) || x.ub != Any)) :
(isa(x,TypeVar) && x.ub != Any && t == x.ub)) &&
Expand Down
2 changes: 1 addition & 1 deletion base/irrationals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ log(::Irrational{:e}, x) = log(x)
# align along = for nice Array printing
function alignment(x::Irrational)
m = match(r"^(.*?)(=.*)$", sprint(showcompact_lim, x))
m == nothing ? (length(sprint(showcompact_lim, x)), 0) :
m === nothing ? (length(sprint(showcompact_lim, x)), 0) :
(length(m.captures[1]), length(m.captures[2]))
end
4 changes: 2 additions & 2 deletions base/latex_symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ for c in child_nodes(root(xdoc))
latex = nothing
for el in ("AMS", "IEEE", "mathlatex", "latex")
latex = find_element(ce, el)
latex != nothing && break
latex !== nothing && break
end
if latex != nothing
if latex !== nothing
L = strip(content(latex))
id = attribute(ce, "id")
U = string(map(s -> Char(parse(Int, s, 16)),
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function eigs(A, B;
which=:LM
end

if sigma != nothing && !iscmplx && isa(sigma,Complex)
if sigma !== nothing && !iscmplx && isa(sigma,Complex)
throw(ArgumentError("complex shifts for real problems are not yet supported"))
end
sigma = isshift ? convert(T,sigma) : zero(T)
Expand Down
16 changes: 8 additions & 8 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
function find_source_file(file)
(isabspath(file) || isfile(file)) && return file
file2 = find_in_path(file)
file2 != nothing && return file2
file2 !== nothing && return file2
file2 = joinpath(JULIA_HOME, DATAROOTDIR, "julia", "base", file)
isfile(file2) ? file2 : nothing
end
Expand Down Expand Up @@ -68,9 +68,9 @@ function _require_from_serialized(node::Int, path_to_try::ByteString, toplevel_l
content = remotecall_fetch(node, open, readbytes, path_to_try)
end
restored = _include_from_serialized(content)
if restored != nothing
if restored !== nothing
others = filter(x -> x != myid(), procs())
refs = Any[ @spawnat p (nothing != _include_from_serialized(content)) for p in others]
refs = Any[ @spawnat p (nothing !== _include_from_serialized(content)) for p in others]
for (id, ref) in zip(others, refs)
if !fetch(ref)
warn("node state is inconsistent: node $id failed to load cache from $path_to_try")
Expand All @@ -91,7 +91,7 @@ function _require_from_serialized(node::Int, mod::Symbol, toplevel_load::Bool)
paths = @fetchfrom node find_all_in_cache_path(mod)
for path_to_try in paths
restored = _require_from_serialized(node, path_to_try, toplevel_load)
if restored == nothing
if restored === nothing
warn("deserialization checks failed while attempting to load cache from $path_to_try")
else
return restored
Expand Down Expand Up @@ -120,7 +120,7 @@ function require(mod::Symbol)
try
toplevel_load = false
restored = _require_from_serialized(1, mod, last)
if restored != nothing
if restored !== nothing
for M in restored
if isdefined(M, :__META__)
push!(Base.Docs.modules, M)
Expand All @@ -131,7 +131,7 @@ function require(mod::Symbol)
if JLOptions().incremental != 0
# spawn off a new incremental compile task from node 1 for recursive `require` calls
cachefile = compile(mod)
if nothing == _require_from_serialized(1, cachefile, last)
if nothing === _require_from_serialized(1, cachefile, last)
warn("require failed to create a precompiled cache file")
end
return
Expand Down Expand Up @@ -189,7 +189,7 @@ macro __FILE__() source_path() end

function include_from_node1(path::AbstractString)
prev = source_path(nothing)
path = (prev == nothing) ? abspath(path) : joinpath(dirname(prev),path)
path = (prev === nothing) ? abspath(path) : joinpath(dirname(prev),path)
tls = task_local_storage()
tls[:SOURCE_PATH] = path
local result
Expand All @@ -203,7 +203,7 @@ function include_from_node1(path::AbstractString)
result = include_string(remotecall_fetch(1, readall, path), path)
end
finally
if prev == nothing
if prev === nothing
delete!(tls, :SOURCE_PATH)
else
tls[:SOURCE_PATH] = prev
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/Common/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function list(stream::IO, block::MD)
withstream(stream) do
eatindent(stream) || return false
b = startswith(stream, num_or_bullets)
(b == nothing || b == "") && return false
(b === nothing || b == "") && return false
ordered = !(b[1] in bullets)
if ordered
b = b[end - 1] == '.' ? r"^\d+\. " : r"^\d+\) "
Expand Down
6 changes: 3 additions & 3 deletions base/markdown/Common/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
@trigger '*' ->
function asterisk_italic(stream::IO, md::MD)
result = parse_inline_wrapper(stream, "*")
return result == nothing ? nothing : Italic(parseinline(result, md))
return result === nothing ? nothing : Italic(parseinline(result, md))
end

type Bold
Expand All @@ -21,7 +21,7 @@ end
@trigger '*' ->
function asterisk_bold(stream::IO, md::MD)
result = parse_inline_wrapper(stream, "**")
return result == nothing ? nothing : Bold(parseinline(result, md))
return result === nothing ? nothing : Bold(parseinline(result, md))
end

# ––––
Expand All @@ -31,7 +31,7 @@ end
@trigger '`' ->
function inline_code(stream::IO, md::MD)
result = parse_inline_wrapper(stream, "`"; rep=true)
return result == nothing ? nothing : Code(result)
return result === nothing ? nothing : Code(result)
end

# ––––––––––––––
Expand Down
6 changes: 3 additions & 3 deletions base/markdown/GitHub/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ function github_table(stream::IO, md::MD)
rows = []
cols = 0
align = nothing
while (row = parserow(stream)) != nothing
while (row = parserow(stream)) !== nothing
if length(rows) == 0
row[1] == "" && return false
cols = length(row)
end
if align == nothing && length(rows) == 1 # Must have a --- row
if align === nothing && length(rows) == 1 # Must have a --- row
align = parsealign(row)
(align == nothing || length(align) != cols) && return false
(align === nothing || length(align) != cols) && return false
else
push!(rows, map(x -> parseinline(x, md), rowlength!(row, cols)))
end
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/IPython/IPython.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end
@trigger '$' ->
function tex(stream::IO, md::MD)
result = parse_inline_wrapper(stream, "\$", rep = true)
return result == nothing ? nothing : LaTeX(result)
return result === nothing ? nothing : LaTeX(result)
end

function blocktex(stream::IO, md::MD)
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/parse/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function parseinline(stream::IO, md::MD, config::Config)
while !eof(stream)
char = peek(stream)
if haskey(config.inner, char) &&
(inner = parseinline(stream, md, config.inner[char])) != nothing
(inner = parseinline(stream, md, config.inner[char])) !== nothing
c = takebuf_string(buffer)
!isempty(c) && push!(content, c)
buffer = IOBuffer()
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/parse/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function startswith(stream::IO, r::Regex; eat = true, padding = false)
line = chomp(readline(stream))
seek(stream, start)
m = match(r, line)
m == nothing && return ""
m === nothing && return ""
eat && @dotimes length(m.match) read(stream, Char)
return m.match
end
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/render/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function withtag(f, io::IO, tag, attrs...)
htmlesc(io, value)
print(io, "\"")
end
f == nothing && return print(io, " />")
f === nothing && return print(io, " />")

print(io, ">")
f()
Expand Down
2 changes: 1 addition & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
show(io::IO, mt::MethodTable) = show_method_table(io, mt)

inbase(m::Module) = m == Base ? true : m == Main ? false : inbase(module_parent(m))
fileurl(file) = let f = find_source_file(file); f == nothing ? "" : "file://"*f; end
fileurl(file) = let f = find_source_file(file); f === nothing ? "" : "file://"*f; end
function url(m::Method)
M = m.func.code.module
(m.func.code.file == :null || m.func.code.file == :string) && return ""
Expand Down
4 changes: 2 additions & 2 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ end

function parse_connection_info(str)
m = match(r"^julia_worker:(\d+)#(.*)", str)
if m != nothing
if m !== nothing
(m.captures[2], parse(Int16, m.captures[1]))
else
("", Int16(-1))
Expand Down Expand Up @@ -1414,7 +1414,7 @@ function pmap(f, lsts...; err_retry=true, err_stop=false, pids = workers())
for (pididx, wpid) in enumerate(pids)
@async begin
tasklet = getnext_tasklet()
while (tasklet != nothing)
while (tasklet !== nothing)
(idx, fvals) = tasklet
busy_workers[pididx] = true
try
Expand Down
Loading

0 comments on commit b92b537

Please sign in to comment.