mirror of
https://github.com/uutils/coreutils.git
synced 2026-05-06 07:26:38 -04:00
sort: add collation key arena storage to LineData
Add collation_key_buffer (arena) and collation_key_ends (offsets) to LineData and RecycledChunk, with a collation_key() accessor. All sort keys for a chunk are stored in a single Vec<u8> to avoid millions of small heap allocations.
This commit is contained in:
@@ -62,6 +62,11 @@ pub struct LineData<'a> {
|
||||
impl LineData<'_> {
|
||||
/// Get the collation sort key for a line at the given index.
|
||||
pub fn collation_key(&self, index: usize) -> &[u8] {
|
||||
debug_assert!(
|
||||
index < self.collation_key_ends.len(),
|
||||
"collation_key index {index} out of bounds (len {})",
|
||||
self.collation_key_ends.len()
|
||||
);
|
||||
let start = if index == 0 {
|
||||
0
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user