Date: Wed, 08 Jan 2020 01:09:52 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 242828] diff -rq still does full file comparison Message-ID: <bug-242828-227-LfHSXpqpw7@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-242828-227@https.bugs.freebsd.org/bugzilla/> References: <bug-242828-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242828 --- Comment #1 from fehmi noyan isi <fnoyanisi@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.help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-242828-227-LfHSXpqpw7>
