Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47109:33e5511b571a
rust: Remove DirstateMap::file_fold_map
This was a HashMap constructed on demand and then cached in the DirstateMap
struct to avoid reconstructing at the next access. However the only use is
in Python bindings converting it to a PyDict. That method in turn is wrapped
in a @cachedproperty in Python code.
This was two redudant layers of caching. This changeset removes the Rust-level
one to keep the Python dict cache, and have bindings create a PyDict by
iterating.
Differential Revision: https://phab.mercurial-scm.org/D10493
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 13 Apr 2021 17:02:58 +0200 |
parents | 5d62243c7732 |
children | d5956136d19d |
comparison
equal
deleted
inserted
replaced
47108:e3cebe96c0fc | 47109:33e5511b571a |
---|---|
28 use hg::{ | 28 use hg::{ |
29 dirstate::parsers::Timestamp, | 29 dirstate::parsers::Timestamp, |
30 dirstate_tree::dispatch::DirstateMapMethods, | 30 dirstate_tree::dispatch::DirstateMapMethods, |
31 errors::HgError, | 31 errors::HgError, |
32 revlog::Node, | 32 revlog::Node, |
33 utils::files::normalize_case, | |
33 utils::hg_path::{HgPath, HgPathBuf}, | 34 utils::hg_path::{HgPath, HgPathBuf}, |
34 DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, | 35 DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, |
35 DirstateMapError, DirstateParents, EntryState, StateMapIter, | 36 DirstateMapError, DirstateParents, EntryState, StateMapIter, |
36 }; | 37 }; |
37 | 38 |
327 } | 328 } |
328 } | 329 } |
329 | 330 |
330 def filefoldmapasdict(&self) -> PyResult<PyDict> { | 331 def filefoldmapasdict(&self) -> PyResult<PyDict> { |
331 let dict = PyDict::new(py); | 332 let dict = PyDict::new(py); |
332 for (key, value) in | 333 for (path, entry) in self.inner(py).borrow_mut().iter() { |
333 self.inner(py).borrow_mut().build_file_fold_map().iter() | 334 if entry.state != EntryState::Removed { |
334 { | 335 let key = normalize_case(path); |
335 dict.set_item( | 336 let value = path; |
336 py, | 337 dict.set_item( |
337 PyBytes::new(py, key.as_bytes()).into_object(), | 338 py, |
338 PyBytes::new(py, value.as_bytes()).into_object(), | 339 PyBytes::new(py, key.as_bytes()).into_object(), |
339 )?; | 340 PyBytes::new(py, value.as_bytes()).into_object(), |
341 )?; | |
342 } | |
340 } | 343 } |
341 Ok(dict) | 344 Ok(dict) |
342 } | 345 } |
343 | 346 |
344 def __len__(&self) -> PyResult<usize> { | 347 def __len__(&self) -> PyResult<usize> { |