Skip to content

Commit 8370133

Browse files
authored
Several ! invalidation fixes (#35887)
Together, these eliminate more than a thousand invalidations from defining struct Not end Base.:!(::Not) = true
1 parent fe59346 commit 8370133

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

base/show.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ end
11351135

11361136
function show_unquoted_quote_expr(io::IO, @nospecialize(value), indent::Int, prec::Int, quote_level::Int)
11371137
if isa(value, Symbol) && !(value in quoted_syms)
1138+
value = value::Symbol
11381139
s = string(value)
11391140
if isidentifier(s) || (isoperator(value) && value !== Symbol("'"))
11401141
print(io, ":")
@@ -1144,6 +1145,7 @@ function show_unquoted_quote_expr(io::IO, @nospecialize(value), indent::Int, pre
11441145
end
11451146
else
11461147
if isa(value,Expr) && value.head === :block
1148+
value = value::Expr
11471149
show_block(IOContext(io, beginsym=>false), "quote", value, indent, quote_level)
11481150
print(io, "end")
11491151
else

base/stream.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function isopen(x::Union{LibuvStream, LibuvServer})
320320
if x.status == StatusUninit || x.status == StatusInit
321321
throw(ArgumentError("$x is not initialized"))
322322
end
323-
return x.status != StatusClosed && x.status != StatusEOF
323+
return x.status::Int != StatusClosed && x.status::Int != StatusEOF
324324
end
325325

326326
function check_open(x::Union{LibuvStream, LibuvServer})
@@ -395,7 +395,7 @@ function close(stream::Union{LibuvStream, LibuvServer})
395395
stream.status = StatusClosing
396396
elseif isopen(stream) || stream.status == StatusEOF
397397
should_wait = uv_handle_data(stream) != C_NULL
398-
if stream.status != StatusClosing
398+
if stream.status::Int != StatusClosing
399399
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), stream.handle)
400400
stream.status = StatusClosing
401401
end
@@ -410,7 +410,7 @@ function uvfinalize(uv::Union{LibuvStream, LibuvServer})
410410
iolock_begin()
411411
if uv.handle != C_NULL
412412
disassociate_julia_struct(uv.handle) # not going to call the usual close hooks
413-
if uv.status != StatusUninit
413+
if uv.status::Int != StatusUninit
414414
close(uv)
415415
else
416416
Libc.free(uv.handle)
@@ -524,7 +524,7 @@ function uv_alloc_buf(handle::Ptr{Cvoid}, size::Csize_t, buf::Ptr{Cvoid})
524524
stream = unsafe_pointer_to_objref(hd)::LibuvStream
525525

526526
local data::Ptr{Cvoid}, newsize::Csize_t
527-
if stream.status != StatusActive
527+
if stream.status::Int != StatusActive
528528
data = C_NULL
529529
newsize = 0
530530
else
@@ -557,7 +557,7 @@ function uv_readcb(handle::Ptr{Cvoid}, nread::Cssize_t, buf::Ptr{Cvoid})
557557
if isa(stream, TTY)
558558
stream.status = StatusEOF # libuv called uv_stop_reading already
559559
notify(stream.cond)
560-
elseif stream.status != StatusClosing
560+
elseif stream.status::Int != StatusClosing
561561
# begin shutdown of the stream
562562
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), stream.handle)
563563
stream.status = StatusClosing
@@ -667,7 +667,7 @@ show(io::IO, stream::Pipe) = print(io,
667667

668668
function open_pipe!(p::PipeEndpoint, handle::OS_HANDLE)
669669
iolock_begin()
670-
if p.status != StatusInit
670+
if p.status::Int != StatusInit
671671
error("pipe is already in use or has been closed")
672672
end
673673
err = ccall(:uv_pipe_open, Int32, (Ptr{Cvoid}, OS_HANDLE), p.handle, handle)
@@ -1061,7 +1061,7 @@ _fd(x::Union{OS_HANDLE, RawFD}) = x
10611061

10621062
function _fd(x::Union{LibuvStream, LibuvServer})
10631063
fd = Ref{OS_HANDLE}(INVALID_OS_HANDLE)
1064-
if x.status != StatusUninit && x.status != StatusClosed
1064+
if x.status::Int != StatusUninit && x.status::Int != StatusClosed
10651065
err = ccall(:uv_fileno, Int32, (Ptr{Cvoid}, Ptr{OS_HANDLE}), x.handle, fd)
10661066
# handle errors by returning INVALID_OS_HANDLE
10671067
end

base/strings/basic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ function thisind(s::AbstractString, i::Int)
421421
z = ncodeunits(s) + 1
422422
i == z && return i
423423
@boundscheck 0  i z || throw(BoundsError(s, i))
424-
@inbounds while 1 < i && !isvalid(s, i)
424+
@inbounds while 1 < i && !(isvalid(s, i)::Bool)
425425
i -= 1
426426
end
427427
return i

base/util.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ text_colors
6868

6969
function with_output_color(f::Function, color::Union{Int, Symbol}, io::IO, args...; bold::Bool = false)
7070
buf = IOBuffer()
71-
iscolor = get(io, :color, false)
71+
iscolor = get(io, :color, false)::Bool
7272
try f(IOContext(buf, io), args...)
7373
finally
7474
str = String(take!(buf))

base/version.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function ident_cmp(
154154
B::Tuple{Vararg{Union{Integer,String}}},
155155
)
156156
for (a, b) in zip(A, B)
157-
c = ident_cmp(a,b)
157+
c = ident_cmp(a,b)::Int
158158
(c != 0) && return c
159159
end
160160
length(A) < length(B) ? -1 :

stdlib/Logging/src/ConsoleLogger.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ function handle_message(logger::ConsoleLogger, level, message, _module, group, i
128128
# Format lines as text with appropriate indentation and with a box
129129
# decoration on the left.
130130
color,prefix,suffix = logger.meta_formatter(level, _module, group, id, filepath, line)
131+
color = convert(Symbol, color)::Symbol
132+
prefix, suffix = convert(String, prefix)::String, convert(String, suffix)::String
131133
minsuffixpad = 2
132134
buf = IOBuffer()
133135
iob = IOContext(buf, logger.stream)
@@ -161,4 +163,3 @@ function handle_message(logger::ConsoleLogger, level, message, _module, group, i
161163
write(logger.stream, take!(buf))
162164
nothing
163165
end
164-

0 commit comments

Comments
 (0)