mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Instead of doing a manual comparison loop, just use memcmp, thanks to JohnC
for the suggestion! :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e4b6a86852
commit
2ee51cbeb8
@ -17,6 +17,7 @@
|
|||||||
#include "llvm/System/MappedFile.h"
|
#include "llvm/System/MappedFile.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static bool isNumberChar(char C) {
|
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.
|
// Okay, now that we opened the files, scan them for the first difference.
|
||||||
char *File1Start = F1.charBase();
|
char *File1Start = F1.charBase();
|
||||||
char *File2Start = F2.charBase();
|
char *File2Start = F2.charBase();
|
||||||
char *File1End = File1Start+F1.size();
|
char *File1End = File1Start+A_size;
|
||||||
char *File2End = File2Start+F2.size();
|
char *File2End = File2Start+B_size;
|
||||||
char *F1P = File1Start;
|
char *F1P = File1Start;
|
||||||
char *F2P = File2Start;
|
char *F2P = File2Start;
|
||||||
|
|
||||||
if (A_size == B_size) {
|
if (A_size == B_size) {
|
||||||
// Scan for the end of file or first difference.
|
// Are the buffers identical?
|
||||||
while (F1P < File1End && *F1P == *F2P)
|
if (std::memcmp(File1Start, File2Start, A_size) == 0)
|
||||||
++F1P, ++F2P;
|
return 0;
|
||||||
|
|
||||||
// Common case: identifical files.
|
|
||||||
if (F1P == File1End)
|
|
||||||
return 0; // Scanned to end, files same
|
|
||||||
|
|
||||||
if (AbsTol == 0 && RelTol == 0)
|
if (AbsTol == 0 && RelTol == 0)
|
||||||
return 1; // Files different!
|
return 1; // Files different!
|
||||||
|
Loading…
Reference in New Issue
Block a user