mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-16 18:31:14 -03:00
History to store old item offsets in Vec and not VecDeque
We used deque in C++ because this vector may be large, and so it avoids repeated re-allocations. But VecDeque is different in Rust - it's contiguous - so there's no benefit. Just use Vec.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
use crate::{common::cstr2wcstring, env::EnvVar, wcstringutil::trim};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{BTreeMap, HashMap, HashSet, VecDeque},
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
ffi::CString,
|
||||
fs::File,
|
||||
io::{BufRead, Read, Seek, SeekFrom, Write},
|
||||
@@ -379,7 +379,7 @@ struct HistoryImpl {
|
||||
/// Whether we've loaded old items.
|
||||
loaded_old: bool, // false
|
||||
/// List of old items, as offsets into out mmap data.
|
||||
old_item_offsets: VecDeque<usize>,
|
||||
old_item_offsets: Vec<usize>,
|
||||
}
|
||||
|
||||
/// If set, we gave up on file locking because it took too long.
|
||||
@@ -463,7 +463,7 @@ fn populate_from_file_contents(&mut self) {
|
||||
file_contents.offset_of_next_item(&mut cursor, Some(self.boundary_timestamp))
|
||||
{
|
||||
// Remember this item.
|
||||
self.old_item_offsets.push_back(offset);
|
||||
self.old_item_offsets.push(offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,7 +982,7 @@ fn new(name: WString) -> Self {
|
||||
last_identifier: 0,
|
||||
countdown_to_vacuum: None,
|
||||
loaded_old: false,
|
||||
old_item_offsets: VecDeque::new(),
|
||||
old_item_offsets: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user