Skip to content

Commit

Permalink
fix invalidations from loading Static.jl (#46761)
Browse files Browse the repository at this point in the history
* improve type stability of `sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, o::Ordering)`
* improve type stability of `fmt(buf, pos, arg, spec::Spec{T}) where {T <: Strings}`

This fixes some invalidations when loading Static.jl.

(cherry picked from commit 9b1780d)
  • Loading branch information
ranocha authored and KristofferC committed Sep 16, 2022
1 parent 9d593ce commit 85ecb8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ const SMALL_ALGORITHM = InsertionSort
const SMALL_THRESHOLD = 20

function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, o::Ordering)
@inbounds for i = lo+1:hi
lo_plus_1 = (lo + 1)::Integer
@inbounds for i = lo_plus_1:hi
j = i
x = v[i]
while j > lo
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Printf/src/Printf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ end
@inline function fmt(buf, pos, arg, spec::Spec{T}) where {T <: Strings}
leftalign, hash, width, prec = spec.leftalign, spec.hash, spec.width, spec.precision
str = string(arg)
slen = textwidth(str) + (hash ? arg isa AbstractString ? 2 : 1 : 0)
slen = textwidth(str)::Int + (hash ? arg isa AbstractString ? 2 : 1 : 0)
op = p = prec == -1 ? slen : min(slen, prec)
if !leftalign && width > p
for _ = 1:(width - p)
Expand Down

0 comments on commit 85ecb8e

Please sign in to comment.