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

Intern entity paths for faster comparisons. #11711

Closed
wants to merge 1 commit into from

Commits on Feb 5, 2024

  1. Intern entity paths for faster comparisons.

    This patch places all entity paths into a shared table so that comparing
    them is as cheap as a pointer comparison. We don't use the pre-existing
    `Interner` type because that leaks all strings added to it, and I was
    uncomfortable with leaking names, as Bevy apps might dynamically
    generate them. Instead, I reference count all the names and use a linked
    list to stitch together paths into a tree. The interner uses a weak hash
    set from the [`weak-table`] crate.
    
    This patch is especially helpful for the two-phase animation PR bevyengine#11707,
    because two-phase animation gets rid of the cache from name to
    animation-specific slot, thus increasing the load on the hash table that
    maps paths to bone indices.
    
    Note that the interned table is a global variable behind a `OnceLock`
    instead of a resource. This is because it must be accessed from the glTF
    `AssetLoader`, which unfortunately has no access to Bevy resources.
    
    [`weak-table`]: https://crates.io/crates/weak-table
    pcwalton committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    bca3439 View commit details
    Browse the repository at this point in the history