[clang][lex] Avoid `DirectoryLookup` copies
authorJan Svoboda <jan_svoboda@apple.com>
Sat, 15 Oct 2022 15:42:27 +0000 (08:42 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Thu, 20 Oct 2022 23:12:34 +0000 (16:12 -0700)
This patch fixes a performance regression introduced in D121685 that was caused by copying `DirectoryLookup`.

rdar://101206790

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D136019

clang/lib/Lex/HeaderSearch.cpp

index dd82f42..7230345 100644 (file)
@@ -305,7 +305,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
 
   // Look through the various header search paths to load any available module
   // maps, searching for a module map that describes this module.
-  for (DirectoryLookup Dir : search_dir_range()) {
+  for (DirectoryLookup &Dir : search_dir_range()) {
     if (Dir.isFramework()) {
       // Search for or infer a module map for a framework. Here we use
       // SearchName rather than ModuleName, to permit finding private modules