From 1f54f10977379854102a0796dde712a35fe032f3 Mon Sep 17 00:00:00 2001 From: Tortar <68152031+Tortar@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:18:06 +0200 Subject: [PATCH 1/4] Improve performance of sizehint! on BinaryHeap --- src/heaps/binary_heap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heaps/binary_heap.jl b/src/heaps/binary_heap.jl index f3850d5d6..53fa2a2c6 100644 --- a/src/heaps/binary_heap.jl +++ b/src/heaps/binary_heap.jl @@ -39,7 +39,7 @@ mutable struct BinaryHeap{T, O <: Base.Ordering} <: AbstractHeap{T} end function BinaryHeap{T}(ordering::Base.Ordering, xs::AbstractVector) where T - valtree = heapify(xs, ordering) + valtree = @inline heapify!(copyto!(similar(xs), xs), ordering) new{T, typeof(ordering)}(ordering, valtree) end end From f024b0d2f739bb6fff7df1daf2f791fe06f7a14a Mon Sep 17 00:00:00 2001 From: Tortar <68152031+Tortar@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:24:31 +0200 Subject: [PATCH 2/4] Update binary_heap.jl --- src/heaps/binary_heap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heaps/binary_heap.jl b/src/heaps/binary_heap.jl index 53fa2a2c6..41d534545 100644 --- a/src/heaps/binary_heap.jl +++ b/src/heaps/binary_heap.jl @@ -39,7 +39,7 @@ mutable struct BinaryHeap{T, O <: Base.Ordering} <: AbstractHeap{T} end function BinaryHeap{T}(ordering::Base.Ordering, xs::AbstractVector) where T - valtree = @inline heapify!(copyto!(similar(xs), xs), ordering) + valtree = @inline heapify(xs, ordering) new{T, typeof(ordering)}(ordering, valtree) end end From 9f349161b75afbe95b1c199c4f24298ba19c931f Mon Sep 17 00:00:00 2001 From: Tortar <68152031+Tortar@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:24:57 +0200 Subject: [PATCH 3/4] Update arrays_as_heaps.jl --- src/heaps/arrays_as_heaps.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heaps/arrays_as_heaps.jl b/src/heaps/arrays_as_heaps.jl index 483e65093..ffb5fabc4 100644 --- a/src/heaps/arrays_as_heaps.jl +++ b/src/heaps/arrays_as_heaps.jl @@ -75,7 +75,7 @@ end In-place [`heapify`](@ref). """ -function heapify!(xs::AbstractArray, o::Ordering=Forward) +@inline function heapify!(xs::AbstractArray, o::Ordering=Forward) for i in heapparent(length(xs)):-1:1 percolate_down!(xs, i, o) end From de9913b5e072321873817f82c38d7f9672b48b85 Mon Sep 17 00:00:00 2001 From: Tortar <68152031+Tortar@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:25:41 +0200 Subject: [PATCH 4/4] Update binary_heap.jl --- src/heaps/binary_heap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heaps/binary_heap.jl b/src/heaps/binary_heap.jl index 41d534545..f3850d5d6 100644 --- a/src/heaps/binary_heap.jl +++ b/src/heaps/binary_heap.jl @@ -39,7 +39,7 @@ mutable struct BinaryHeap{T, O <: Base.Ordering} <: AbstractHeap{T} end function BinaryHeap{T}(ordering::Base.Ordering, xs::AbstractVector) where T - valtree = @inline heapify(xs, ordering) + valtree = heapify(xs, ordering) new{T, typeof(ordering)}(ordering, valtree) end end