diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-08-27 19:41:31 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-08-27 19:41:31 +0200 |
commit | ce01861e6ef3b652eeafbef5b87c293b3a971d89 (patch) | |
tree | 6f60e5cb5604f00bfe8a29cbc11bd2d754ed220d /src/repository/fs/element.rs | |
parent | 5226132f7e43d0b12d8f58aabef7f5785d5f03fe (diff) | |
parent | 5b52e6a0269eb2a0c3d69a1ce3312ba07d4dc997 (diff) |
Merge branch 'fast-repository-loading'
After some completely non-scientific benchmarking, these patches bring down the
loading time for a real-world repository from over 20 sec to about 17 sec on
debug build of butido and to 5 sec in release build and even to 2 sec after the
filesystem cache got a bit warm.
So I guess we can safely merge this now and be happy with it (and go back to the
more important issues).
Diffstat (limited to 'src/repository/fs/element.rs')
-rw-r--r-- | src/repository/fs/element.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/repository/fs/element.rs b/src/repository/fs/element.rs new file mode 100644 index 0000000..73b97f6 --- /dev/null +++ b/src/repository/fs/element.rs @@ -0,0 +1,33 @@ +// +// Copyright (c) 2020-2021 science+computing ag and other contributors +// +// This program and the accompanying materials are made +// available under the terms of the Eclipse Public License 2.0 +// which is available at https://www.eclipse.org/legal/epl-2.0/ +// +// SPDX-License-Identifier: EPL-2.0 +// + +use std::collections::HashMap; + +use crate::repository::fs::path::PathComponent; + +/// One element in the tree inside FileSystemRepresentation +/// +/// This is either a File, or a Directory that contains more (Files or Directories). +#[derive(Debug)] +pub enum Element { + File(String), + Dir(HashMap<PathComponent, Element>) +} + +impl Element { + /// Helper fn to get the directory contents of the element, if the element is an Element::Dir + pub fn get_map_mut(&mut self) -> Option<&mut HashMap<PathComponent, Element>> { + match self { + Element::File(_) => None, + Element::Dir(ref mut hm) => Some(hm), + } + } +} + |