summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-07-27 08:28:13 +0000
committerJim Meyering <jim@meyering.net>2003-07-27 08:28:13 +0000
commit6013cbabde66a9b2e550512c695f7b4a765a4247 (patch)
treea0ec8712e6b83d7c0eb73828771cb8ae61806cdc /src
parent665f7a2d0f29b31eadcd026a884ed05c480c4d9d (diff)
downloadcoreutils-6013cbabde66a9b2e550512c695f7b4a765a4247.tar.xz
(sort): Don't require two `struct line's per text line,
the new sort algorithm requires just 1.5.
Diffstat (limited to 'src')
-rw-r--r--src/sort.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/sort.c b/src/sort.c
index 4c3a0d5d6..24a0689b6 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1990,11 +1990,12 @@ sort (char **files, int nfiles, char const *output_file)
char const *file = *files;
FILE *fp = xfopen (file, "r");
FILE *tfp;
+ size_t bytes_per_line = 2 * sizeof (struct line) - sizeof (struct line) / 2;
if (! buf.alloc)
- initbuf (&buf, 2 * sizeof (struct line),
+ initbuf (&buf, bytes_per_line,
sort_buffer_size (&fp, 1, files, nfiles,
- 2 * sizeof (struct line), size));
+ bytes_per_line, size));
buf.eof = 0;
files++;
nfiles--;
@@ -2005,9 +2006,8 @@ sort (char **files, int nfiles, char const *output_file)
struct line *linebase;
if (buf.eof && nfiles
- && (2 * sizeof (struct line) + 1
- < (buf.alloc - buf.used
- - 2 * sizeof (struct line) * buf.nlines)))
+ && (bytes_per_line + 1
+ < (buf.alloc - buf.used - bytes_per_line * buf.nlines)))
{
/* End of file, but there is more input and buffer room.
Concatenate the next input file; this is faster in