Skip to content

Commit d79c5d5

Browse files
authored
Merge pull request #856 from JoaoAparicio/allocs
Allocs
2 parents 8ea8e02 + 7f86c4d commit d79c5d5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/balanced_tree.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ function Base.empty!(t::BalancedTree23)
242242
initializeTree!(t.tree)
243243
t.depth = 1
244244
t.rootloc = 1
245-
t.freetreeinds = Vector{Int}()
246-
t.freedatainds = Vector{Int}()
245+
empty!(t.freetreeinds)
246+
empty!(t.freedatainds)
247247
empty!(t.useddatacells)
248248
push!(t.useddatacells, 1, 2)
249249
return nothing

test/test_sorted_containers.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,12 @@ end
20272027

20282028

20292029

2030+
function testSortedAllocs()
2031+
d = SortedDict{Int,Int}(Base.Order.ForwardOrdering())
2032+
x = @allocated empty!(d)
2033+
my_assert(x == 0)
2034+
true
2035+
end
20302036

20312037
@testset "SortedContainers" begin
20322038
@test testSortedDictBasic()
@@ -2038,6 +2044,7 @@ end
20382044
@test testSortedDictConstructors()
20392045
@test testSortedMultiDictConstructors()
20402046
@test testTokens()
2047+
@test testSortedAllocs()
20412048

20422049

20432050
# test all the errors of sorted containers
@@ -2109,4 +2116,3 @@ end
21092116
end
21102117
end
21112118
end
2112-

0 commit comments

Comments
 (0)