From 601cb6b4d8e644b28071682bbe0eb020ba090bb9 Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Thu, 22 May 2025 15:25:38 +0800 Subject: [PATCH] update --- src/Consts.cs | 7 ++++++- src/Internal/Allocators/AllocatorUtility.cs | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Consts.cs b/src/Consts.cs index 4377352..15bff6c 100644 --- a/src/Consts.cs +++ b/src/Consts.cs @@ -89,7 +89,12 @@ namespace DCFApixels.DragonECS #else false; #endif - + public const bool ENABLE_DUMMY_SPAN = +#if ENABLE_DUMMY_SPAN + true; +#else + false; +#endif [Obsolete("DRAGONECS_ENABLE_DEBUG_SERVICE")] diff --git a/src/Internal/Allocators/AllocatorUtility.cs b/src/Internal/Allocators/AllocatorUtility.cs index 7f6a46a..27f608b 100644 --- a/src/Internal/Allocators/AllocatorUtility.cs +++ b/src/Internal/Allocators/AllocatorUtility.cs @@ -10,8 +10,16 @@ namespace DCFApixels.DragonECS.Core.Internal } public static unsafe void ClearAllocatedMemory(byte* ptr, int startByte, int lengthInBytes) { +#if ENABLE_DUMMY_SPAN + lengthInBytes += startByte; + for (int i = startByte; i < lengthInBytes; i++) + { + ptr[i] = 0; + } +#else Span memorySpan = new Span(ptr + startByte, lengthInBytes); memorySpan.Clear(); +#endif } } }