Use a trie to keep track of path states
Dependencies
- [2]
WFWTKCJNCreate initial Visual Studio Code extension - [3]
LQJG2LGQRefactor `PathState` handling to be updated incrementally
Change contents
- edit in pijul-extension/src/path_state.rs at line 12
use patricia_tree::GenericPatriciaMap; - replacement in pijul-extension/src/path_state.rs at line 83
// TODO: use a triepub states: HashMap<Utf8PathBuf, PathState>,states: GenericPatriciaMap<String, PathState>, - replacement in pijul-extension/src/path_state.rs at line 128
let mut untracked_states = HashMap::new();let mut untracked_states = GenericPatriciaMap::new(); - replacement in pijul-extension/src/path_state.rs at line 152
untracked_states.insert(utf8_path, PathState::Untracked);untracked_states.insert(utf8_path.into_string(), PathState::Untracked); - edit in pijul-extension/src/path_state.rs at line 186
let mut updated_states = HashMap::new(); - replacement in pijul-extension/src/path_state.rs at line 192
let entry = self.states.entry(Utf8PathBuf::from(globalized_hunk.path()));let entry = updated_states.entry(globalized_hunk.path().to_string()); - edit in pijul-extension/src/path_state.rs at line 210
// Overwrite the previous path states that were affected, and clear any previous paths// that no longer have an active statelet mut paths_to_remove = Vec::new();for (path, existing_state) in self.states.iter_prefix_mut(prefix) {match updated_states.remove(&path) {Some(updated_state) => {// Update an existing state*existing_state = updated_state;}None => {// There is currently no state attached to this path, so remove itpaths_to_remove.push(path);}}}// Actually clear the paths that no longer have an active state (and aren't untracked)let read_transaction = transaction.read();for outdated_path in paths_to_remove {if read_transaction.is_tracked(&outdated_path)? {self.states.remove(outdated_path);} else {self.states.insert(outdated_path, PathState::Untracked);}}// Insert any new paths that remainfor (path, updated_state) in updated_states {self.states.insert(path, updated_state);} - replacement in pijul-extension/src/path_state.rs at line 245
self.states.get(path).copied()self.states.get(path.as_str()).copied()}pub fn iter_path_states(&self) -> impl Iterator<Item = (Utf8PathBuf, PathState)> {self.states.iter().map(|(path, state)| (Utf8PathBuf::from(path), *state)) - replacement in pijul-extension/src/path_state.rs at line 278
self.states.insert(path, PathState::Untracked);self.states.insert(path.into_string(), PathState::Untracked); - replacement in pijul-extension/src/lib.rs at line 376
pub fn iter_path_states(&self) -> impl Iterator<Item = (&Utf8Path, PathState)> {self.path_states.states.iter().map(|(path, state)| (path.as_path(), *state))pub fn iter_path_states(&self) -> impl Iterator<Item = (Utf8PathBuf, PathState)> {self.path_states.iter_path_states() - edit in pijul-extension/Cargo.toml at line 12
patricia_tree.workspace = true - edit in Cargo.toml at line 44
patricia_tree = "0.10" - edit in Cargo.lock at line 2442
name = "patricia_tree"version = "0.10.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4df0e43512f12f23a6b08c7b893192b7d6ec937b95ee03af040847907fe5cef7"[[package]] - edit in Cargo.lock at line 2511
"patricia_tree",