diff options
| author | Kamil Dudka <kdudka@redhat.com> | 2008-07-30 14:31:50 +0200 |
|---|---|---|
| committer | Jim Meyering <meyering@redhat.com> | 2008-08-01 08:36:38 +0200 |
| commit | 8d974b00fbbc2025de63e1e6d54827648fefa1c4 (patch) | |
| tree | bff56540d745da7ec4287455eaf3ad119bae5441 /src/ls.c | |
| parent | * timeout.c: Fix grammar in a comment. Normalize comment syntax. (diff) | |
| download | coreutils-8d974b00fbbc2025de63e1e6d54827648fefa1c4.tar.gz coreutils-8d974b00fbbc2025de63e1e6d54827648fefa1c4.zip | |
ls -U1 now uses constant memory
When printing one name per line and not sorting, ls now uses
constant memory per directory, no matter how many files are in
the directory.
* ls.c (print_dir): Print each file name immediately, when possible.
* NEWS: Mention the improvement.
Diffstat (limited to 'src/ls.c')
| -rw-r--r-- | src/ls.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2402,6 +2402,20 @@ print_dir (char const *name, char const *realname, bool command_line_arg) #endif total_blocks += gobble_file (next->d_name, type, D_INO (next), false, name); + + /* In this narrow case, print out each name right away, so + ls uses constant memory while processing the entries of + this directory. Useful when there are many (millions) + of entries in a directory. */ + if (format == one_per_line && sort_type == sort_none) + { + /* We must call sort_files in spite of + "sort_type == sort_none" for its initialization + of the sorted_file vector. */ + sort_files (); + print_current_files (); + clear_files (); + } } } else if (errno != 0) |
