Skip to content

Commit

Permalink
convert some equalities to symbols to use === rather than == (JuliaLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly authored Jul 6, 2022
1 parent 3f4fc63 commit 7a21d52
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export
# - LLVM doesn't currently support atomics on floats for ppc64
# C++20 is adding limited support for atomics on float, but as of
# now Clang does not support that yet.
if Sys.ARCH == :i686 || startswith(string(Sys.ARCH), "arm") ||
if Sys.ARCH === :i686 || startswith(string(Sys.ARCH), "arm") ||
Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
const inttypes = (Int8, Int16, Int32, Int64,
UInt8, UInt16, UInt32, UInt64)
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ function statement_cost(ex::Expr, line::Int, src::Union{CodeInfo, IRCode}, sptyp
return 0
end
return error_path ? params.inline_error_path_cost : params.inline_nonleaf_penalty
elseif head === :foreigncall || head === :invoke || head == :invoke_modify
elseif head === :foreigncall || head === :invoke || head === :invoke_modify
# Calls whose "return type" is Union{} do not actually return:
# they are errors. Since these are not part of the typical
# run-time of the function, we omit them from
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/slot2ssa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function domsort_ssa!(ir::IRCode, domtree::DomTree)
result[inst_range[end]][:inst] = GotoIfNot(terminator.cond, bb_rename[terminator.dest])
elseif !isa(terminator, ReturnNode)
if isa(terminator, Expr)
if terminator.head == :enter
if terminator.head === :enter
terminator.args[1] = bb_rename[terminator.args[1]]
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/experimental.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ the MethodTable).
"""
macro max_methods(n::Int, fdef::Expr)
0 < n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.")
(fdef.head == :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration")
(fdef.head === :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration")
return :(typeof($(esc(fdef))).name.max_methods = $(UInt8(n)))
end

Expand Down
2 changes: 1 addition & 1 deletion base/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ rather than line 2 where `@test` is used as an implementation detail.
"""
function replace_sourceloc!(sourceloc, @nospecialize(ex))
if ex isa Expr
if ex.head == :macrocall
if ex.head === :macrocall
ex.args[2] = sourceloc
end
map!(e -> replace_sourceloc!(sourceloc, e), ex.args, ex.args)
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ function bodyfunction(basemethod::Method)
f = nothing
if isa(ast, Core.CodeInfo) && length(ast.code) >= 2
callexpr = ast.code[end-1]
if isa(callexpr, Expr) && callexpr.head == :call
if isa(callexpr, Expr) && callexpr.head === :call
fsym = callexpr.args[1]
if isa(fsym, Symbol)
f = getfield(fmod, fsym)
Expand Down
4 changes: 2 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ function sourceinfo_slotnames(src::CodeInfo)
names = Dict{String,Int}()
printnames = Vector{String}(undef, length(slotnames))
for i in eachindex(slotnames)
if slotnames[i] == :var"#unused#"
if slotnames[i] === :var"#unused#"
printnames[i] = "_"
continue
end
Expand Down Expand Up @@ -2021,7 +2021,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
# other call-like expressions ("A[1,2]", "T{X,Y}", "f.(X,Y)")
elseif haskey(expr_calls, head) && nargs >= 1 # :ref/:curly/:calldecl/:(.)
funcargslike = head === :(.) ? (args[2]::Expr).args : args[2:end]
show_call(head == :ref ? IOContext(io, beginsym=>true) : io, head, args[1], funcargslike, indent, quote_level, head !== :curly)
show_call(head === :ref ? IOContext(io, beginsym=>true) : io, head, args[1], funcargslike, indent, quote_level, head !== :curly)

# comprehensions
elseif head === :typed_comprehension && nargs == 2
Expand Down
4 changes: 2 additions & 2 deletions base/threadingconstructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ function nthreads end

nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint)))
function nthreads(pool::Symbol)
if pool == :default
if pool === :default
tpid = Int8(0)
elseif pool == :interactive
elseif pool === :interactive
tpid = Int8(1)
else
error("invalid threadpool specified")
Expand Down
6 changes: 3 additions & 3 deletions stdlib/Distributed/src/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function launch_on_machine(manager::SSHManager, machine::AbstractString, cnt, pa
end

# Julia process with passed in command line flag arguments
if shell == :posix
if shell === :posix
# ssh connects to a POSIX shell

cmds = "exec $(shell_escape_posixly(exename)) $(shell_escape_posixly(exeflags))"
Expand All @@ -297,7 +297,7 @@ function launch_on_machine(manager::SSHManager, machine::AbstractString, cnt, pa
# shell login (-l) with string command (-c) to launch julia process
remotecmd = shell_escape_posixly(`sh -l -c $cmds`)

elseif shell == :csh
elseif shell === :csh
# ssh connects to (t)csh

remotecmd = "exec $(shell_escape_csh(exename)) $(shell_escape_csh(exeflags))"
Expand All @@ -313,7 +313,7 @@ function launch_on_machine(manager::SSHManager, machine::AbstractString, cnt, pa
remotecmd = "cd $(shell_escape_csh(dir))\n$remotecmd"
end

elseif shell == :wincmd
elseif shell === :wincmd
# ssh connects to Windows cmd.exe

any(c -> c == '"', exename) && throw(ArgumentError("invalid exename"))
Expand Down
4 changes: 2 additions & 2 deletions stdlib/InteractiveUtils/src/clipboard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD
_clipboardcmd !== nothing && return _clipboardcmd
for cmd in (:xclip, :xsel, :wlclipboard)
# wl-clipboard ships wl-copy/paste individually
c = cmd == :wlclipboard ? Symbol("wl-copy") : cmd
c = cmd === :wlclipboard ? Symbol("wl-copy") : cmd
success(pipeline(`which $c`, devnull)) && return _clipboardcmd = cmd
end
pkgs = @static if Sys.KERNEL === :FreeBSD
Expand Down Expand Up @@ -83,7 +83,7 @@ elseif Sys.iswindows()
x_u16 = Base.cwstring(x)
pdata = Ptr{UInt16}(C_NULL)
function cleanup(cause)
errno = cause == :success ? UInt32(0) : Libc.GetLastError()
errno = cause === :success ? UInt32(0) : Libc.GetLastError()
if cause !== :OpenClipboard
if cause !== :success && pdata != C_NULL
ccall((:GlobalFree, "kernel32"), stdcall, Cint, (Ptr{UInt16},), pdata)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/lbt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ function Base.show(io::IO, mime::MIME{Symbol("text/plain")}, lbt::LBTConfig)
println(io, "Libraries: ")
for (i,l) in enumerate(lbt.loaded_libs)
char = i == length(lbt.loaded_libs) ? "" : ""
interface_str = if l.interface == :ilp64
interface_str = if l.interface === :ilp64
"ILP64"
elseif l.interface == :lp64
elseif l.interface === :lp64
" LP64"
else
"UNKWN"
Expand Down
6 changes: 3 additions & 3 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function print(io::IO,
tasks::Union{UInt,AbstractVector{UInt}} = typemin(UInt):typemax(UInt))

pf = ProfileFormat(;C, combine, maxdepth, mincount, noisefloor, sortedby, recur)
if groupby == :none
if groupby === :none
print(io, data, lidict, pf, format, threads, tasks, false)
else
if !in(groupby, [:thread, :task, [:task, :thread], [:thread, :task]])
Expand Down Expand Up @@ -285,15 +285,15 @@ function print(io::IO,
end
end
end
elseif groupby == :task
elseif groupby === :task
threads = 1:typemax(Int)
for taskid in intersect(get_task_ids(data), tasks)
printstyled(io, "Task $(Base.repr(taskid)) "; bold=true, color=Base.debug_color())
nosamples = print(io, data, lidict, pf, format, threads, taskid, true)
nosamples && (any_nosamples = true)
println(io)
end
elseif groupby == :thread
elseif groupby === :thread
tasks = 1:typemax(UInt)
for threadid in intersect(get_thread_ids(data), threads)
printstyled(io, "Thread $threadid "; bold=true, color=Base.info_color())
Expand Down
4 changes: 2 additions & 2 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,9 @@ end
function edit_input(s, f = (filename, line, column) -> InteractiveUtils.edit(filename, line, column))
mode_name = guess_current_mode_name(s)
filename = tempname()
if mode_name == :julia
if mode_name === :julia
filename *= ".jl"
elseif mode_name == :shell
elseif mode_name === :shell
filename *= ".sh"
end
buf = buffer(s)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ function check_for_missing_packages_and_run_hooks(ast)
end

function modules_to_be_loaded(ast::Expr, mods::Vector{Symbol} = Symbol[])
ast.head == :quote && return mods # don't search if it's not going to be run during this eval
if ast.head in [:using, :import]
ast.head === :quote && return mods # don't search if it's not going to be run during this eval
if ast.head === :using || ast.head === :import
for arg in ast.args
arg = arg::Expr
arg1 = first(arg.args)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ fake_repl() do stdin_write, stdout_read, repl
# necessary to read at least some part of the buffer,
# for the "region_active" to have time to be updated

@test LineEdit.state(repl.mistate).region_active == :off
@test LineEdit.state(repl.mistate).region_active === :off
@test s4 == "anything" # no control characters between the last two occurrences of "anything"
write(stdin_write, "\x15\x04")
Base.wait(repltask)
Expand Down

0 comments on commit 7a21d52

Please sign in to comment.