summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FileUtilities.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-02-15 22:12:10 +0000
committerChris Lattner <sabre@nondot.org>2005-02-15 22:12:10 +0000
commit3e7a193bd7ee0932892546d0842cfedd037886a4 (patch)
tree94deaf9bc6ccdb516bd3f4baf742355dd826b677 /llvm/lib/Support/FileUtilities.cpp
parent9d0db6f60293b0fba9a8e84f1d80f6093d2f7413 (diff)
downloadbcm5719-llvm-3e7a193bd7ee0932892546d0842cfedd037886a4.tar.gz
bcm5719-llvm-3e7a193bd7ee0932892546d0842cfedd037886a4.zip
Instead of doing a manual comparison loop, just use memcmp, thanks to JohnC
for the suggestion! :) llvm-svn: 20203
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
-rw-r--r--llvm/lib/Support/FileUtilities.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index 6ac9bc91bc3..0a6e154d926 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/lib/Support/FileUtilities.cpp
@@ -17,6 +17,7 @@
#include "llvm/System/MappedFile.h"
#include "llvm/ADT/StringExtras.h"
#include <cmath>
+#include <cstring>
using namespace llvm;
static bool isNumberChar(char C) {
@@ -141,19 +142,15 @@ int llvm::DiffFilesWithTolerance(const sys::Path &FileA,
// Okay, now that we opened the files, scan them for the first difference.
char *File1Start = F1.charBase();
char *File2Start = F2.charBase();
- char *File1End = File1Start+F1.size();
- char *File2End = File2Start+F2.size();
+ char *File1End = File1Start+A_size;
+ char *File2End = File2Start+B_size;
char *F1P = File1Start;
char *F2P = File2Start;
if (A_size == B_size) {
- // Scan for the end of file or first difference.
- while (F1P < File1End && *F1P == *F2P)
- ++F1P, ++F2P;
-
- // Common case: identifical files.
- if (F1P == File1End)
- return 0; // Scanned to end, files same
+ // Are the buffers identical?
+ if (std::memcmp(File1Start, File2Start, A_size) == 0)
+ return 0;
if (AbsTol == 0 && RelTol == 0)
return 1; // Files different!
OpenPOWER on IntegriCloud