Skip to content

Avoid hacky workaround for with_capacity #5

Closed
@jonhoo

Description

@jonhoo

When we have to allocate a new table, we want to continue with factor-of-two resizing when possible. Unfortunately, hashbrown::RawTable::with_capacity (I think) allocates more or less the capacity we give it, rather than rounding up. So, we resort to this workaround:

griddle/src/lib.rs

Lines 746 to 749 in c68eb4c

// We want to favor factor-of-two growing, if that's sufficient, so we don't
// use with_capacity (which allocates _exactly_ what we give).
let mut new_table = RawTable::new();
new_table.reserve(need_cap, |_| unreachable!());

It'd be nice to get rid of that. Benchmarks may tell us that with_capacity works just fine..

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions