From da0dc58a44b7caed160e69c656f31d6fd5ddb9a4 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Tue, 5 May 2015 16:50:19 -0400 Subject: [PATCH] restore performance of integer shift operators. These were calling convert, which generally works, but is slow as it checks the conversion from Int to Int32, somewhat unnecessarily. --- base/operators.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/operators.jl b/base/operators.jl index 173aa34e213d6..e2ea6f4377791 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -111,9 +111,9 @@ const .≠ = .!= <<(x,y::Int32) = no_op_err("<<", typeof(x)) >>(x,y::Int32) = no_op_err(">>", typeof(x)) >>>(x,y::Int32) = no_op_err(">>>", typeof(x)) -<<(x,y::Integer) = x << convert(Int32,y) ->>(x,y::Integer) = x >> convert(Int32,y) ->>>(x,y::Integer) = x >>> convert(Int32,y) +<<(x,y::Integer) = x << (y % Int32) +>>(x,y::Integer) = x >> (y % Int32) +>>>(x,y::Integer) = x >>> (y % Int32) # fallback div, fld, and cld implementations # NOTE: C89 fmod() and x87 FPREM implicitly provide truncating float division,