From d67688b922fccdb00cfeda6fc71d58f3219afe4a Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 01:15:52 +0300 Subject: [PATCH] Optimizes --- source/Cosmos.Core/MemoryBlock.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/Cosmos.Core/MemoryBlock.cs b/source/Cosmos.Core/MemoryBlock.cs index 86fd242af..dbf6d4c17 100644 --- a/source/Cosmos.Core/MemoryBlock.cs +++ b/source/Cosmos.Core/MemoryBlock.cs @@ -120,7 +120,7 @@ namespace Cosmos.Core { throw new Exception("Memory access violation"); } - for (int i = 0; i < aBuffer.Length; i++) + for (int i = 0; i < aBuffer.Length / 2; i++) (*(Byte*)(Base + i)) = aBuffer[i]; } @@ -130,8 +130,11 @@ namespace Cosmos.Core { throw new Exception("Memory access violation"); } - for (int i = 0; i < aBuffer.Length; i++) - aBuffer[i] = (*(UInt16*)(Base + i)); + for (int i = 0; i < aBuffer.Length / 2; i++) + { + aBuffer[i*2+0] = (*(UInt16*)(Base + i*2+0)); + aBuffer[i*2+1] = (*(UInt16*)(Base + i*2+1)); + } } public unsafe void Write16(UInt16[] aBuffer) @@ -140,8 +143,11 @@ namespace Cosmos.Core { throw new Exception("Memory access violation"); } - for (int i = 0; i < aBuffer.Length; i++) - (*(UInt16*)(Base + i)) = aBuffer[i]; + for (int i = 0; i < aBuffer.Length / 2; i++) + { + (*(UInt16*)(Base + i*2+0)) = aBuffer[i*2+0]; + (*(UInt16*)(Base + i*2+1)) = aBuffer[i*2+1]; + } } public unsafe void Read32(UInt32[] aBuffer)