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

Faster version "World.Get<T>(Entity entity)" #209

Closed
leveljiujiu opened this issue Mar 15, 2024 · 3 comments
Closed

Faster version "World.Get<T>(Entity entity)" #209

leveljiujiu opened this issue Mar 15, 2024 · 3 comments

Comments

@leveljiujiu
Copy link

leveljiujiu commented Mar 15, 2024

The new version is 30% faster than the original.

    public ref T Get<T>(Entity entity)
    {
        ref var slots = ref EntityInfo.EntitySlots[entity.Id];
        ref var slot = ref slots.Slot;
        return ref slots.Archetype.Chunks[slot.ChunkIndex].GetArray<T>()[slot.Index];
    }
@leveljiujiu
Copy link
Author

Unity2022.3.20f1
3A2C16E1-092E-4eac-9E76-C385F1584EE6

@genaray
Copy link
Owner

genaray commented Mar 15, 2024

Can you create an official benchmark in arch to verify this for the repo?

@leveljiujiu
Copy link
Author

Sorry. My bad. This difference only exists in Unity, they are not different in the benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants