From aeea84a69374d95cdcfc2e4467091dc3ed75e2c9 Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 5 Dec 2015 20:26:36 +0400 Subject: [PATCH] (CopyOverlapped): slightly optimized BlockCopy loop. --- GameRes/Utility.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index c0ffc262..de099d5c 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -73,15 +73,12 @@ namespace GameRes.Utility public static void CopyOverlapped (byte[] data, int src, int dst, int count) { - int preceding = dst-src; - if (preceding > 0) + if (dst > src) { while (count > 0) { - if (preceding > count) - preceding = count; + int preceding = System.Math.Min (dst - src, count); System.Buffer.BlockCopy (data, src, data, dst, preceding); - src = dst; dst += preceding; count -= preceding; }