mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
perf(linter/import/no-cycle): don't allocate paths already seen (#27478)
We always allocate (by `.clone()`) a new path, even just for checking membership. Instead, we use borrowed data for the membership check and then only clone a new path when we insert new data, dramatically reducing allocations needed. Running on `vscode`: Metric | Before | After | Change -- | -- | -- | -- `no-cycle` allocations | 33,072,678 | 19,051,530 | −42.4% `no-cycle` allocated bytes | 2.738 GB | 1.700 GB | −37.9%
This commit is contained in:
1 parent
1515d53c9f
commit
73e877c43c
1 file changed
+2
-1
@@ -205,9 +205,10 @@ impl ModuleGraphVisitor {
|
||||
}
|
||||
|
||||
let path = &loaded_module_record.resolved_absolute_path;
|
||||
if !self.traversed.insert(path.clone()) {
|
||||
if self.traversed.contains(path) {
|
||||
continue;
|
||||
}
|
||||
self.traversed.insert(path.clone());
|
||||
|
||||
self.depth += 1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user