ahoppen added a comment. Nice. I think this reads a lot better than the index-based implementation.
================ Comment at: clang/lib/Lex/HeaderSearch.cpp:1450 Optional<unsigned> HeaderSearch::searchDirIdx(const DirectoryLookup &DL) const { - for (unsigned I = 0; I < SearchDirs.size(); ++I) - if (&SearchDirs[I] == &DL) - return I; - return None; + return &DL - &*SearchDirs.begin(); } ---------------- Could we change this function to return an `unsigned` instead of `Optional<unsigned>` now? Also, is `&DL - &*SearchDirs.begin()` safe and doesn’t trigger the issues we saw previously if start and end are allocated in different memory regions, because I don’t know. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119722/new/ https://reviews.llvm.org/D119722 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits