From 43c5adc6cc5bd42955ddd4408973279bac4cccb6 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 2 Jul 2023 21:39:44 +0800 Subject: [PATCH] usafe optimise GetEntityLong --- src/EcsWorld.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index c42513d..415e8b0 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -201,7 +201,11 @@ namespace DCFApixels.DragonECS ReleaseDelEntityBuffer(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public entlong GetEntityLong(int entityID) => new entlong(entityID, _gens[entityID], id); //TODO придумать получше имя метода + public unsafe entlong GetEntityLong(int entityID) + { + long x = ((long)id << 48 | (long)_gens[entityID] << 32 | entityID); + return *(entlong*)&x; + } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool IsAlive(int entityID, short gen) => _gens[entityID] == gen; [MethodImpl(MethodImplOptions.AggressiveInlining)]