[Bug 242828] diff -rq still does full file comparison

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Jan 8 01:09:54 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242828

--- Comment #1 from fehmi noyan isi <fnoyanisi at yahoo.com> ---
It appears BSD diff keeps working on the the files even after it knows whether
the files are identical or not. 

In diffreg(), which is called by diff() we have [1]

        switch (files_differ(f1, f2, flags)) {
        case 0:
                goto closem;
        case 1:
                break;
        default:
                /* error */
                status |= 2;
                goto closem;
        }

files_differ() returns 0 when the files are identical and 1 when they are
different. For the cases when files_differ() returns 1, instead of just a
single break statement, we can add a check for the command line arguments and
if '-q' supplied, i.e. D_BRIEF, then we should return from diffred() (after
doing some housekeeping if necessary - or add another 'goto' label at the end
of the function).

Instead, BSD diff carries on and hashes each line in both files, sorts them and
do more checks, hence taking more time.

If this sounds reasonable, I can work on a patch.

[1] http://src.illumos.org/source/xref/freebsd-head/usr.bin/diff/diffreg.c#341

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list