Skip to content

Commit 345ce78

Browse files
authored
remove unnecessary ::Union{} type asserts (#35817)
* remove unnecessary ::Union{} type asserts
1 parent ae3a3cc commit 345ce78

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

base/char.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ end
8282
struct CodePointError{T<:Integer} <: Exception
8383
code::T
8484
end
85-
@noinline invalid_char(c::AbstractChar) = throw(InvalidCharError(c))
86-
@noinline code_point_err(u::Integer) = throw(CodePointError(u))
85+
@noinline throw_invalid_char(c::AbstractChar) = throw(InvalidCharError(c))
86+
@noinline throw_code_point_err(u::Integer) = throw(CodePointError(u))
8787

8888
function ismalformed(c::Char)
8989
u = reinterpret(UInt32, c)
@@ -129,7 +129,7 @@ function UInt32(c::Char)
129129
t0 = trailing_zeros(u) & 56
130130
(l1 == 1) | (8l1 + t0 > 32) |
131131
((((u & 0x00c0c0c0) 0x00808080) >> t0 != 0) | is_overlong_enc(u)) &&
132-
invalid_char(c)::Union{}
132+
throw_invalid_char(c)
133133
u &= 0xffffffff >> l1
134134
u >>= t0
135135
((u & 0x0000007f) >> 0) | ((u & 0x00007f00) >> 2) |
@@ -157,7 +157,7 @@ end
157157

158158
function Char(u::UInt32)
159159
u < 0x80 && return reinterpret(Char, u << 24)
160-
u < 0x00200000 || code_point_err(u)::Union{}
160+
u < 0x00200000 || throw_code_point_err(u)
161161
c = ((u << 0) & 0x0000003f) | ((u << 2) & 0x00003f00) |
162162
((u << 4) & 0x003f0000) | ((u << 6) & 0x3f000000)
163163
c = u < 0x00000800 ? (c << 16) | 0xc0800000 :

stdlib/LibGit2/src/LibGit2.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,15 @@ end
963963

964964
const ENSURE_INITIALIZED_LOCK = ReentrantLock()
965965

966+
@noinline function throw_negative_refcount_error(x::Int)
967+
error("Negative LibGit2 REFCOUNT $x\nThis shouldn't happen, please file a bug report!")
968+
end
969+
966970
function ensure_initialized()
967971
lock(ENSURE_INITIALIZED_LOCK) do
968972
x = Threads.atomic_cas!(REFCOUNT, 0, 1)
969973
x > 0 && return
970-
x < 0 && negative_refcount_error(x)::Union{}
974+
x < 0 && throw_negative_refcount_error(x)
971975
try initialize()
972976
catch
973977
Threads.atomic_sub!(REFCOUNT, 1)
@@ -978,10 +982,6 @@ function ensure_initialized()
978982
return nothing
979983
end
980984

981-
@noinline function negative_refcount_error(x::Int)
982-
error("Negative LibGit2 REFCOUNT $x\nThis shouldn't happen, please file a bug report!")
983-
end
984-
985985
@noinline function initialize()
986986
@check ccall((:git_libgit2_init, :libgit2), Cint, ())
987987

test/char.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@test widen('a') === 'a'
2121
# just check this works
22-
@test_throws Base.CodePointError Base.code_point_err(UInt32(1))
22+
@test_throws Base.CodePointError Base.throw_code_point_err(UInt32(1))
2323
end
2424

2525
@testset "ASCII conversion to/from Integer" begin

0 commit comments

Comments
 (0)