Skip to content

Commit f09df45

Browse files
ranochaKristofferC
authored andcommitted
specialize hastypemax on Bool (#42300)
Since `Bool` is not included in `Base.BitIntegerType`, `hastypemax(Bool)` falls back to the slow generic version. This reduces the performance of `digits!` with Boolean target vector (for `base=2`) significantly. Specializing `hastypemax` on `Bool` fixes this performance bug. (cherry picked from commit e50603f)
1 parent f6e3388 commit f09df45

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

base/intfuncs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ end
864864
Return true if and only if the extrema `typemax(T)` and `typemin(T)` are defined.
865865
"""
866866
hastypemax(::Base.BitIntegerType) = true
867+
hastypemax(::Type{Bool}) = true
867868
hastypemax(::Type{T}) where {T} = applicable(typemax, T) && applicable(typemin, T)
868869

869870
"""

0 commit comments

Comments
 (0)