From 38f2425aeb55c87e809e5c0ffba748f7fed61c36 Mon Sep 17 00:00:00 2001
From: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Date: Mon, 24 Jun 2024 21:09:40 -0700
Subject: [PATCH] Improve patch creation performance - Skip MD5 hash generation
 if the file size differs, as it's guaranteed to be different - Disable xdelta
 compression, LZMA does a better job and quicker

---
 Patcher/PatcherUtils/PatchHelper.cs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Patcher/PatcherUtils/PatchHelper.cs b/Patcher/PatcherUtils/PatchHelper.cs
index 9e5fcd0..698336e 100644
--- a/Patcher/PatcherUtils/PatchHelper.cs
+++ b/Patcher/PatcherUtils/PatchHelper.cs
@@ -83,6 +83,12 @@ namespace PatcherUtils
             var sourceInfo = new FileInfo(SourceFilePath);
             var targetInfo = new FileInfo(TargetFilePath);
 
+            // Return false if file size differs
+            if (sourceInfo.Length != targetInfo.Length)
+            {
+                return false;
+            }
+
             using (MD5 md5Service = MD5.Create())
             using (var sourceStream = File.OpenRead(SourceFilePath))
             using (var targetStream = File.OpenRead(TargetFilePath))
@@ -166,7 +172,7 @@ namespace PatcherUtils
             Process.Start(new ProcessStartInfo
                 {
                     FileName = LazyOperations.XDelta3Path,
-                    Arguments = $"-0 -e -f -s \"{SourceFilePath}\" \"{TargetFilePath}\" \"{deltaPath}\"",
+                    Arguments = $"-0 -e -f -S none -s \"{SourceFilePath}\" \"{TargetFilePath}\" \"{deltaPath}\"",
                     CreateNoWindow = true
                 })
                 .WaitForExit();
-- 
2.47.2