================ @@ -337,33 +337,34 @@ FileOptionsBaseProvider::FileOptionsBaseProvider( void FileOptionsBaseProvider::addRawFileOptions( llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) { auto CurSize = CurOptions.size(); - // Look for a suitable configuration file in all parent directories of the // file. Start with the immediate parent directory and move up. - StringRef Path = llvm::sys::path::parent_path(AbsolutePath); - for (StringRef CurrentPath = Path; !CurrentPath.empty(); - CurrentPath = llvm::sys::path::parent_path(CurrentPath)) { - std::optional<OptionsSource> Result; - - auto Iter = CachedOptions.find(CurrentPath); - if (Iter != CachedOptions.end()) - Result = Iter->second; - - if (!Result) - Result = tryReadConfigFile(CurrentPath); - - if (Result) { - // Store cached value for all intermediate directories. - while (Path != CurrentPath) { + StringRef RootPath = llvm::sys::path::parent_path(AbsolutePath); + auto MemorizedConfigFile = + [this, &RootPath](StringRef CurrentPath) -> std::optional<OptionsSource> { + auto Iter = CachedOptions.Memorized.find(CurrentPath); ---------------- 5chmidti wrote:
nit: can be `const`, and can be declared as the if-init var to reduce its scope https://github.com/llvm/llvm-project/pull/121406 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits