Skip to content
Snippets Groups Projects
  • Josh Megnauth's avatar
    d6ac5f89
    Avoid over allocations & reallocations · d6ac5f89
    Josh Megnauth authored
    As we know, vectors amortize the cost of adding new elements by reserving
    space for multiple elements when full. This is useful but may lead to
    allocating more memory than necessary.
    
    `relibc` generally avoids over allocations by reserving the exact amount
    of space when possible. I fixed a few areas that still over allocated or
    reallocated unnecessarily by leveraging iterators that are more likely
    to know sizes.
    Verified
    d6ac5f89
    History
    Avoid over allocations & reallocations
    Josh Megnauth authored
    As we know, vectors amortize the cost of adding new elements by reserving
    space for multiple elements when full. This is useful but may lead to
    allocating more memory than necessary.
    
    `relibc` generally avoids over allocations by reserving the exact amount
    of space when possible. I fixed a few areas that still over allocated or
    reallocated unnecessarily by leveraging iterators that are more likely
    to know sizes.