MCPcopy Create free account
hub / github.com/angular/angular / insert

Method insert

packages/compiler-cli/preprocessor/ng-analyze/src/query/engine.rs:3318–3346  ·  view source on GitHub ↗
(&mut self, path: PathBuf, key: SourceKey, value: V)

Source from the content-addressed store, hash-verified

3316 }
3317
3318 pub(super) fn insert(&mut self, path: PathBuf, key: SourceKey, value: V) {
3319 let source_len = key.len;
3320 // A single file this large would evict most of the cache for one entry.
3321 if source_len > self.max_source_bytes / 4 {
3322 return;
3323 }
3324 self.clock += 1;
3325 self.remove(&path);
3326 while self.total_source_bytes + source_len > self.max_source_bytes {
3327 let Some(lru) = self
3328 .entries
3329 .iter()
3330 .min_by_key(|(_, entry)| entry.last_used)
3331 .map(|(path, _)| path.clone())
3332 else {
3333 break;
3334 };
3335 self.remove(&lru);
3336 }
3337 self.total_source_bytes += source_len;
3338 self.entries.insert(
3339 path,
3340 Entry {
3341 value,
3342 source: key,
3343 last_used: self.clock,
3344 },
3345 );
3346 }
3347
3348 fn remove(&mut self, path: &Path) {
3349 if let Some(entry) = self.entries.remove(path) {

Callers 15

changed_module_filesMethod · 0.45
get_scope_of_moduleMethod · 0.45
resolve_moduleMethod · 0.45
get_exported_scopeMethod · 0.45
resolve_dts_moduleMethod · 0.45
mark_file_dirtyMethod · 0.45
kind_changedMethod · 0.45
record_dependenciesMethod · 0.45
invalidate_file_idMethod · 0.45

Calls 4

mapMethod · 0.80
removeMethod · 0.65
cloneMethod · 0.65
iterMethod · 0.45