Skip to content

Implement efficient unshifting #9058

@headius

Description

@headius

Prompted by #9056. See https://bugs.ruby-lang.org/issues/6638 for a CRuby issue that led to a similar change there.

Unshift should not only shift elements over by one when reallocating, since that will force every future unshift to copy all elements every time. If a user does unshift once, they are likely to do additional unshifts (or at least less likely to push values at the end), so make sure the expanded space accommodates that use case.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions