Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allocate when creating an empty BTree #50352

Merged
merged 7 commits into from
May 12, 2018

Commits on May 8, 2018

  1. Make LeafNode #[repr(C)] and put the metadata before generic items

    This way we can safely statically allocate a LeafNode to use as the
    placeholder before allocating, and any type accessing it will be able to
    access the metadata at the same offset.
    porglezomp committed May 8, 2018
    Configuration menu
    Copy the full SHA
    669bd82 View commit details
    Browse the repository at this point in the history
  2. Add a statically allocated empty node for empty maps

    This gives a pointer to that static empty node instead of allocating
    a new node, and then whenever inserting makes sure that the root
    isn't that empty node.
    porglezomp committed May 8, 2018
    Configuration menu
    Copy the full SHA
    ef6060c View commit details
    Browse the repository at this point in the history
  3. Don't drop the shared static node

    We modify the drop implementation in IntoIter to not drop the shared root
    porglezomp committed May 8, 2018
    Configuration menu
    Copy the full SHA
    fa62eba View commit details
    Browse the repository at this point in the history
  4. Split into_slices() to avoid making extra slices

    This splits into_slices() into into_key_slice() and into_val_slice(). While the
    extra calls would get optimized out, this is a useful semantic change since we
    call keys() while iterating, and we don't want to construct and out-of-bounds
    val() pointer in the process if we happen to be pointing to the shared static
    root.
    
    This also paves the way for doing the alignment handling conditional differently
    for the keys and values.
    porglezomp committed May 8, 2018
    Configuration menu
    Copy the full SHA
    5b94e9f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ddacf03 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f3a3599 View commit details
    Browse the repository at this point in the history
  7. Make an ensure_root_is_owned method to reduce duplication

    Also remove some unnecessary debug_assert! when creating the shared
    root, since the root should be stored in the rodata and thus be
    impossible to accidentally modify.
    porglezomp committed May 8, 2018
    Configuration menu
    Copy the full SHA
    e83c18f View commit details
    Browse the repository at this point in the history