Skip to content

Commit 39d24bb

Browse files
KristofferCtkelman
authored andcommitted
inline shift operators (#22083)
inline some shift operators (cherry picked from commit 2c73e9c)
1 parent 5dc6c03 commit 39d24bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

base/operators.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ julia> bits(Int8(12))
480480
See also [`>>`](@ref), [`>>>`](@ref).
481481
"""
482482
function <<(x::Integer, c::Integer)
483+
@_inline_meta
483484
typemin(Int) <= c <= typemax(Int) && return x << (c % Int)
484485
(x >= 0 || c >= 0) && return zero(x)
485486
oftype(x, -1)
@@ -518,6 +519,7 @@ julia> bits(Int8(-4))
518519
See also [`>>>`](@ref), [`<<`](@ref).
519520
"""
520521
function >>(x::Integer, c::Integer)
522+
@_inline_meta
521523
typemin(Int) <= c <= typemax(Int) && return x >> (c % Int)
522524
(x >= 0 || c < 0) && return zero(x)
523525
oftype(x, -1)
@@ -551,8 +553,10 @@ is equivalent to [`>>`](@ref).
551553
552554
See also [`>>`](@ref), [`<<`](@ref).
553555
"""
554-
>>>(x::Integer, c::Integer) =
556+
function >>>(x::Integer, c::Integer)
557+
@_inline_meta
555558
typemin(Int) <= c <= typemax(Int) ? x >>> (c % Int) : zero(x)
559+
end
556560
>>>(x::Integer, c::Unsigned) = c <= typemax(UInt) ? x >>> (c % UInt) : zero(x)
557561
>>>(x::Integer, c::Int) = c >= 0 ? x >>> unsigned(c) : x << unsigned(-c)
558562

0 commit comments

Comments
 (0)