fpcmp: Fix bug where fpcmp wouldn't early exit when files obviously differ and
authorDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 19:20:30 +0000 (19:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 19:20:30 +0000 (19:20 +0000)
no tolerance is set.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106033 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/FileUtilities.cpp

index 11c1e02ababb0723a8d07ecd2098aac42d1b1195..1bde2fe8a8717bd52e8725c4dc8e04821d622322 100644 (file)
@@ -212,16 +212,16 @@ int llvm::DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
   const char *F1P = File1Start;
   const char *F2P = File2Start;
 
-  if (A_size == B_size) {
-    // Are the buffers identical?  Common case: Handle this efficiently.
-    if (std::memcmp(File1Start, File2Start, A_size) == 0)
-      return 0;
+  // Are the buffers identical?  Common case: Handle this efficiently.
+  if (A_size == B_size &&
+      std::memcmp(File1Start, File2Start, A_size) == 0)
+    return 0;
 
-    if (AbsTol == 0 && RelTol == 0) {
-      if (Error)
-        *Error = "Files differ without tolerance allowance";
-      return 1;   // Files different!
-    }
+  // Otherwise, we are done a tolerances are set.
+  if (AbsTol == 0 && RelTol == 0) {
+    if (Error)
+      *Error = "Files differ without tolerance allowance";
+    return 1;   // Files different!
   }
 
   bool CompareFailed = false;