[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Feb 15 14:12:23 PST 2005
Changes in directory llvm/lib/Support:
FileUtilities.cpp updated: 1.42 -> 1.43
---
Log message:
Instead of doing a manual comparison loop, just use memcmp, thanks to JohnC
for the suggestion! :)
---
Diffs of the changes: (+6 -9)
FileUtilities.cpp | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.42 llvm/lib/Support/FileUtilities.cpp:1.43
--- llvm/lib/Support/FileUtilities.cpp:1.42 Tue Feb 15 16:01:43 2005
+++ llvm/lib/Support/FileUtilities.cpp Tue Feb 15 16:12:10 2005
@@ -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 @@
// 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!
More information about the llvm-commits
mailing list