Skip to content

Commit

Permalink
Simplify vreverse
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jun 13, 2024
1 parent 29ed673 commit 1d61ddf
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/Sorting/quicksort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,9 @@ end
@inline function vreverse!(A, iₗ, iᵤ)
N = (iᵤ - iₗ) + 1
n = (N ÷ 2) - 1
if N < 32
@inbounds for i 0:n
𝔦ₗ, 𝔦ᵤ = iₗ+i, iᵤ-i
A[𝔦ₗ], A[𝔦ᵤ] = A[𝔦ᵤ], A[𝔦ₗ]
end
else
@inbounds @simd ivdep for i 0:n
𝔦ₗ = iₗ+i
𝔦ᵤ = iᵤ-i
l = A[𝔦ₗ]
u = A[𝔦ᵤ]
A[𝔦ₗ] = u
A[𝔦ᵤ] = l
end
@inbounds for i 0:n
𝔦ₗ, 𝔦ᵤ = iₗ+i, iᵤ-i
A[𝔦ₗ], A[𝔦ᵤ] = A[𝔦ᵤ], A[𝔦ₗ]
end
return A
end
Expand Down

0 comments on commit 1d61ddf

Please sign in to comment.