From 01d4efc22bcb947581f479e7fed21f9d0b28f643 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Fri, 29 Jul 2005 11:13:09 +0000 Subject: [PATCH] PATCH: [ 1245773 ] Scan full files in quick contents compare --- Src/DiffWrapper.cpp | 28 +++++++++++++++++++++++----- Src/readme.txt | 4 ++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index d859d997c..874f76be0 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -1716,7 +1716,7 @@ int DiffFileData::byte_compare_files() ByteComparator comparator(ignore_case_flag, ignore_space_change_flag , ignore_all_space_flag, ignore_eol_diff, ignore_blank_lines_flag); - while (1) + while (!eof[0] && !eof[1]) { // load or update buffers as appropriate for (i=0; i<2; ++i) @@ -1758,15 +1758,32 @@ int DiffFileData::byte_compare_files() comparator.ResetIgnore(); } - // are these two buffers the same? - if (!comparator.CompareBuffers(ptr0, ptr1, end0, end1, eof[0], eof[1])) - return diffcode | DIFFCODE::DIFF; +// We need option to bail out when first diff is found? Might be a good optimization +// in some cases. But then we won't detect all binary files? + + // Don't bother comparing if we already have detected buffers differ + // But we must advance pointers so we can scan full files for binary status + if (!(diffcode & DIFFCODE::DIFF)) + { + // are these two buffers the same? + if (!comparator.CompareBuffers(ptr0, ptr1, end0, end1, eof[0], eof[1])) + { + diffcode |= DIFFCODE::DIFF; + ptr0 = end0; + ptr1 = end1; + } + } + else + { + ptr0 = end0; + ptr1 = end1; + } // did we finish both files? if (eof[0] && eof[1]) { - if (ptr0 == end0 && ptr1 == end1) + if (ptr0 == end0 && ptr1 == end1 && !(diffcode & DIFFCODE::DIFF)) return diffcode | DIFFCODE::SAME; else return diffcode | DIFFCODE::DIFF; @@ -1778,6 +1795,7 @@ int DiffFileData::byte_compare_files() bfstart[0] += ptr0-orig0; bfstart[1] += ptr1-orig1; } + return diffcode; } /** diff --git a/Src/readme.txt b/Src/readme.txt index 340496c4b..1702e02ba 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2005-07-29 Kimmo + PATCH: [ 1245773 ] Scan full files in quick contents compare + Src: DiffWrapper.cpp + 2005-07-26 Kimmo PATCH: [ 1208493 ] Suggest change in title of codepage options Src: Merge.rc -- 2.11.0