diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/ls.c | 14 |
2 files changed, 17 insertions, 0 deletions
@@ -51,6 +51,9 @@ GNU coreutils NEWS -*- outline -*- join has significantly better performance due to better memory management + ls now uses constant memory when not sorting and using one_per_line format, + no matter how many files are in a given directory + od now aligns fields across lines when printing multiple -t specifiers, and no longer prints fields that resulted entirely from padding the input out to the least common multiple width. @@ -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) |