Skip to content

Improve efficiency of resize operation #8

@andrewthecodertx

Description

@andrewthecodertx

The current resize function works by creating a new, larger table and then iterating through the old table, calling hash_table_insert for each element. This re-hashes every key and involves a copy and destroy cycle for every key and value, leading to unnecessary memory allocations and copies (malloc/memcpy/free).

The resize implementation can be made more efficient by directly transferring ownership of the key and value pointers from the old entries array to the new one, without calling the copy/destroy handlers. The re-hashing would still be necessary to find the new bucket index, but the expensive data copying can be avoided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions