Optimize Single Sort IO
Sort a small, single file input directly to the output file,
bypassing the temporaries files that are normally used.
Notes
If the last file to sort can be sorted in memory,
and no temporary files were created for any other input files,
then the output file for this last sort is directed to the final
output file. This avoids a copy from the intermediate file
when a single small file is sorted.
This only applies when the the Sort concern is extended with the
SrcSpec (multiple input file) and LargeInput concerns.
- Declare output file pointer (tfp)
-
Variable declaration
- Segment Source
- 1562: FILE *fp, *tfp;
- Select output file
- Code insertion
- Segment Source
-
1587: if (feof (fp) && !nfiles && !n_temp_files && !buf.left)
1588: tfp = ofp;
- Use output file
-
Argument modification
- Notes
- Changes "ofp" to "tfp".
- Segment Source
-
1598: write_bytes (lines.lines[i].text, lines.lines[i].length, tfp);
1599: putc (eolchar, tfp);
- Close output file
- Code insertion
- Segment Source
-
1601: if (tfp != ofp)
1602: xfclose (tfp);