mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
Improve performance of `sort -m' on large files, at the cost of
making some contrived examples unsafe. POSIX allows this optimization. Performance problem reported by Jonathan Baker in <http://mail.gnu.org/archive/html/bug-coreutils/2004-05/msg00071.html>. (first_same_file): Do not treat input pipes differently from other files.
This commit is contained in:
1 parent
f64a45d112
commit
8e0b4648a6
1 file changed
+2
-4
+2
-4
@@ -1878,9 +1878,7 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp)
|
||||
}
|
||||
|
||||
/* Return the index of the first of NFILES FILES that is the same file
|
||||
as OUTFILE. If none can be the same, return NFILES. Consider an
|
||||
input pipe to be the same as OUTFILE, since the pipe might be the
|
||||
output of a command like "cat OUTFILE". */
|
||||
as OUTFILE. If none can be the same, return NFILES. */
|
||||
|
||||
static int
|
||||
first_same_file (char * const *files, int nfiles, char const *outfile)
|
||||
@@ -1910,7 +1908,7 @@ first_same_file (char * const *files, int nfiles, char const *outfile)
|
||||
? fstat (STDIN_FILENO, &instat)
|
||||
: stat (files[i], &instat))
|
||||
== 0)
|
||||
&& (S_ISFIFO (instat.st_mode) || SAME_INODE (instat, outstat)))
|
||||
&& SAME_INODE (instat, outstat))
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user