From 43eee07270bf1966ea7289310066aa670c4b647f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 8 Feb 2009 01:00:10 +0000 Subject: [PATCH] use some references to simplify code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64063 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/InitHeaderSearch.cpp | 39 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/Driver/InitHeaderSearch.cpp b/lib/Driver/InitHeaderSearch.cpp index 3e4bf29c78..4c25012115 100644 --- a/lib/Driver/InitHeaderSearch.cpp +++ b/lib/Driver/InitHeaderSearch.cpp @@ -280,18 +280,20 @@ static void RemoveDuplicates(std::vector &SearchList, for (unsigned i = 0; i != SearchList.size(); ++i) { unsigned DirToRemove = i; - if (SearchList[i].isNormalDir()) { + const DirectoryLookup &CurEntry = SearchList[i]; + + if (CurEntry.isNormalDir()) { // If this isn't the first time we've seen this dir, remove it. - if (SeenDirs.insert(SearchList[i].getDir())) + if (SeenDirs.insert(CurEntry.getDir())) continue; - } else if (SearchList[i].isFramework()) { + } else if (CurEntry.isFramework()) { // If this isn't the first time we've seen this framework dir, remove it. - if (SeenFrameworkDirs.insert(SearchList[i].getFrameworkDir())) + if (SeenFrameworkDirs.insert(CurEntry.getFrameworkDir())) continue; } else { - assert(SearchList[i].isHeaderMap() && "Not a headermap or normal dir?"); + assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); // If this isn't the first time we've seen this headermap, remove it. - if (SeenHeaderMaps.insert(SearchList[i].getHeaderMap())) + if (SeenHeaderMaps.insert(CurEntry.getHeaderMap())) continue; } @@ -302,27 +304,26 @@ static void RemoveDuplicates(std::vector &SearchList, // // Since dupes of system dirs are rare, just rescan to find the original // that we're nuking instead of using a DenseMap. - if (SearchList[i].getDirCharacteristic() != SrcMgr::C_User) { + if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { // Find the dir that this is the same of. unsigned FirstDir; for (FirstDir = 0; ; ++FirstDir) { assert(FirstDir != i && "Didn't find dupe?"); + const DirectoryLookup &SearchEntry = SearchList[FirstDir]; + // If these are different lookup types, then they can't be the dupe. - if (SearchList[FirstDir].getLookupType() != - SearchList[i].getLookupType()) + if (SearchEntry.getLookupType() != CurEntry.getLookupType()) continue; bool isSame; - if (SearchList[i].isNormalDir()) - isSame = SearchList[FirstDir].getDir() == SearchList[i].getDir(); - else if (SearchList[i].isFramework()) - isSame = SearchList[FirstDir].getFrameworkDir() == - SearchList[i].getFrameworkDir(); + if (CurEntry.isNormalDir()) + isSame = SearchEntry.getDir() == CurEntry.getDir(); + else if (CurEntry.isFramework()) + isSame = SearchEntry.getFrameworkDir() == CurEntry.getFrameworkDir(); else { - assert(SearchList[i].isHeaderMap() && "Not a headermap or normal dir?"); - isSame = SearchList[FirstDir].getHeaderMap() == - SearchList[i].getHeaderMap(); + assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?"); + isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap(); } if (isSame) @@ -336,8 +337,8 @@ static void RemoveDuplicates(std::vector &SearchList, } if (Verbose) { - fprintf(stderr, "ignoring duplicate directory \"%s\"\n", - SearchList[i].getName()); + fprintf(stderr, "ignoring duplicate directory \"%s\"\n", + CurEntry.getName()); if (DirToRemove != i) fprintf(stderr, " as it is a non-system directory that duplicates" " a system directory\n"); -- 2.40.0