diff options
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r-- | crates/vfs/src/file_set.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index 348b6dbfd..0a4590c8d 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs | |||
@@ -83,7 +83,12 @@ impl fmt::Debug for FileSet { | |||
83 | /// ``` | 83 | /// ``` |
84 | #[derive(Debug)] | 84 | #[derive(Debug)] |
85 | pub struct FileSetConfig { | 85 | pub struct FileSetConfig { |
86 | /// Number of sets that `self` can partition a [`Vfs`] into. | ||
87 | /// | ||
88 | /// This should be the number of sets in `self.map` + 1 for files that don't fit in any | ||
89 | /// defined set. | ||
86 | n_file_sets: usize, | 90 | n_file_sets: usize, |
91 | /// Map from encoded paths to the set they belong to. | ||
87 | map: fst::Map<Vec<u8>>, | 92 | map: fst::Map<Vec<u8>>, |
88 | } | 93 | } |
89 | 94 | ||
@@ -111,9 +116,15 @@ impl FileSetConfig { | |||
111 | } | 116 | } |
112 | res | 117 | res |
113 | } | 118 | } |
119 | |||
120 | /// Number of sets that `self` can partition a [`Vfs`] into. | ||
114 | fn len(&self) -> usize { | 121 | fn len(&self) -> usize { |
115 | self.n_file_sets | 122 | self.n_file_sets |
116 | } | 123 | } |
124 | |||
125 | /// Returns the set index for the given `path`. | ||
126 | /// | ||
127 | /// `scratch_space` is used as a buffer and will be entirely replaced. | ||
117 | fn classify(&self, path: &VfsPath, scratch_space: &mut Vec<u8>) -> usize { | 128 | fn classify(&self, path: &VfsPath, scratch_space: &mut Vec<u8>) -> usize { |
118 | scratch_space.clear(); | 129 | scratch_space.clear(); |
119 | path.encode(scratch_space); | 130 | path.encode(scratch_space); |
@@ -169,11 +180,15 @@ impl FileSetConfigBuilder { | |||
169 | } | 180 | } |
170 | } | 181 | } |
171 | 182 | ||
183 | /// Implements [`fst::Automaton`] | ||
184 | /// | ||
185 | /// It will match if `prefix_of` is a prefix of the given data. | ||
172 | struct PrefixOf<'a> { | 186 | struct PrefixOf<'a> { |
173 | prefix_of: &'a [u8], | 187 | prefix_of: &'a [u8], |
174 | } | 188 | } |
175 | 189 | ||
176 | impl<'a> PrefixOf<'a> { | 190 | impl<'a> PrefixOf<'a> { |
191 | /// Creates a new `PrefixOf` from the given slice. | ||
177 | fn new(prefix_of: &'a [u8]) -> Self { | 192 | fn new(prefix_of: &'a [u8]) -> Self { |
178 | Self { prefix_of } | 193 | Self { prefix_of } |
179 | } | 194 | } |