mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2026-04-21 17:35:56 +08:00
fix mem alloc
This commit is contained in:
parent
b6953c919c
commit
b6e43f98fb
@ -97,8 +97,8 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
public EcsUnsafeSpan Execute()
|
||||
{
|
||||
Execute_Iternal();
|
||||
var result = new EcsUnsafeSpan(World.ID, _filteredAllEntities.Ptr, _filteredAllEntitiesCount);
|
||||
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||
var result = new EcsUnsafeSpan(World.ID, _filteredAllEntities.Ptr, _filteredAllEntitiesCount);
|
||||
using (EcsGroup group = EcsGroup.New(World))
|
||||
{
|
||||
foreach (var e in World.Entities)
|
||||
@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
return new EcsUnsafeSpan(World.ID, _filteredAllEntities.Ptr, _filteredAllEntitiesCount); ;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsUnsafeSpan ExecuteFor(EcsSpan span)
|
||||
@ -129,8 +129,8 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
return Execute();
|
||||
}
|
||||
ExecuteFor_Iternal(span);
|
||||
var result = new EcsUnsafeSpan(World.ID, _filteredEntities.Ptr, _filteredEntitiesCount);
|
||||
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||
var result = new EcsUnsafeSpan(World.ID, _filteredEntities.Ptr, _filteredEntitiesCount);
|
||||
foreach (var e in result)
|
||||
{
|
||||
if (World.IsMatchesMask(Mask, e) == false)
|
||||
@ -139,7 +139,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
return new EcsUnsafeSpan(World.ID, _filteredEntities.Ptr, _filteredEntitiesCount); ;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@ -278,6 +278,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
public readonly T* Ptr;
|
||||
public readonly int Length;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal HMem(Handler handler, int length)
|
||||
{
|
||||
Ptr = handler.As<T>();
|
||||
@ -300,8 +301,8 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
get { return Handler.FromDataPtr(Ptr); }
|
||||
}
|
||||
|
||||
public HMem<U> As<U>()
|
||||
where U : unmanaged
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public HMem<U> As<U>() where U : unmanaged
|
||||
{
|
||||
if (IsCreated)
|
||||
{
|
||||
@ -329,7 +330,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public override string ToString() { return DebuggerDisplay(); }
|
||||
public override string ToString() { return Handler.DebuggerDisplay(); }
|
||||
#endif
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override int GetHashCode() { return RawPtr.GetHashCode(); }
|
||||
@ -342,7 +343,9 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(HMem<T> a, HMem<T> b) { return a.Ptr != b.Ptr; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<T> AsSpan() { return new Span<T>(Ptr, Length); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<T> AsSpan(int length)
|
||||
{
|
||||
#if DEBUG
|
||||
@ -350,6 +353,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
#endif
|
||||
return new Span<T>(Ptr, length);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator Handler(HMem<T> memory) { return memory.Handler; }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user