Skip to content

prepend! allocates when X is empty even when there's capacity again #58640

Open
@dpinol

Description

@dpinol

#56029 fixed allocations when inserting at the beginning of a vector even when there was capacity.
However, the fix only works with "large" vectors. With small ones (5 or less in my tests), it allocates even if there's capacity (and the capacity is not affected either)
Reproducible on julia 1.11.5 & 1.12beta3 & master

const x=Vector{Int}(undef, 5);
empty!(x) 
@time insert!(x, 1, 10)

0.000001 seconds (1 allocation: 96 bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]good first issueIndicates a good issue for first-time contributors to JuliaperformanceMust go fasterregression 1.11Regression in the 1.11 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions