mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
sort: improve memory usage for extsort
This commit is contained in:
parent
c38373946a
commit
8c9faa16b9
1 changed files with 4 additions and 1 deletions
|
@ -113,7 +113,7 @@ pub fn ext_sort(
|
|||
|
||||
chunk.push(seq);
|
||||
|
||||
if total_read >= settings.buffer_size {
|
||||
if total_read + chunk.len() * std::mem::size_of::<Line>() >= settings.buffer_size {
|
||||
super::sort_by(&mut chunk, &settings);
|
||||
write_chunk(
|
||||
settings,
|
||||
|
@ -136,6 +136,9 @@ pub fn ext_sort(
|
|||
iter.chunks += 1;
|
||||
}
|
||||
|
||||
// We manually drop here to not go over our memory limit when we allocate below.
|
||||
drop(chunk);
|
||||
|
||||
// initialize buffers for each chunk
|
||||
//
|
||||
// Having a right sized buffer for each chunk for smallish values seems silly to me?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue