Skip to content

possible optimization for sheep #72

Description

@pazz

the dimension is fixed, so we could consider fixing the capacity of the vectors representing sheep:

https://www.reddit.com/r/learnrust/comments/12eczea/how_much_faster_are_arrays_that_vecs_and_is_my/?rdt=48521

if you know in advance (at runtime) the number of elements you need, you can use Vec::with_capacity to reserve enough space up front - for large arrays, this essentially makes the malloc cost disappear, as the cost of the actual operation dominates the cost of malloc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions