@joebigelow / wix / commits / c29c96b7

Minor CompareFiles optimization when source/target are same path

Rob Mensching committed Mar 25, 2021 at 06:02 UTC c29c96b72c3ba2fcfa06da54c7fe3750bce4168b
2 files changed +7 -1
src/WixToolset.Core.WindowsInstaller/Bind/FileSystemManager.cs
+6
@@ -2,6 +2,7 @@
2
3 namespace WixToolset.Core.WindowsInstaller.Bind
4 {
5 + using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using WixToolset.Extensibility;
@@ -31,6 +32,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
32
33 private static bool BuiltinCompareFiles(string firstPath, string secondPath)
34 {
35 + if (String.Equals(firstPath, secondPath, StringComparison.OrdinalIgnoreCase))
36 + {
37 + return true;
38 + }
39 +
40 using (var firstStream = File.OpenRead(firstPath))
41 using (var secondStream = File.OpenRead(secondPath))
42 {
src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesFromTransforms.cs
+1 -1
@@ -91,7 +91,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
91 {
92 // TODO: should this entire condition be placed in the binder file manager?
93 if (/*(0 == (PatchAttributeType.Ignore & mainWixFileRow.PatchAttributes)) &&*/
94 - !this.FileSystemManager.CompareFiles(objectField.PreviousData.ToString(), objectField.Data.ToString()))
94 + !this.FileSystemManager.CompareFiles(objectField.PreviousData, objectField.Data.ToString()))
95 {
96 // If the file is different, we need to mark the mainFileRow and pairedFileRow as modified.
97 mainFileRow.Operation = RowOperation.Modify;