summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-05-14 07:34:09 +0000
committerJim Meyering <jim@meyering.net>2004-05-14 07:34:09 +0000
commit8e0b4648a613daa8a4f01a058a2a7ffb982eafcd (patch)
tree5762481d4a7652eb08a29fe773118b77ee6fa392
parentf64a45d11280dab075ce04344375e39a15f86602 (diff)
downloadcoreutils-8e0b4648a613daa8a4f01a058a2a7ffb982eafcd.tar.xz
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.
-rw-r--r--src/sort.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/sort.c b/src/sort.c
index a259ae974..6fcfc69d7 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -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;
}