aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-01-15 15:39:40 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-01-15 15:39:40 +0000
commitee791dde723a2089c681d2ab6a9d4f96379d5f49 (patch)
treea6082d4d1d1e9ddaea09a6a04bb4a47da95d642d /lib/Lex/HeaderMap.cpp
parentabe15e553e58165e7692c0d0842865c488ed7b45 (diff)
downloadsrc-ee791dde723a2089c681d2ab6a9d4f96379d5f49.tar.gz
src-ee791dde723a2089c681d2ab6a9d4f96379d5f49.zip
Update clang to r93512.
Notes
Notes: svn path=/vendor/clang/dist/; revision=202379
Diffstat (limited to 'lib/Lex/HeaderMap.cpp')
-rw-r--r--lib/Lex/HeaderMap.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/Lex/HeaderMap.cpp b/lib/Lex/HeaderMap.cpp
index df712760bb25..4010d613ac24 100644
--- a/lib/Lex/HeaderMap.cpp
+++ b/lib/Lex/HeaderMap.cpp
@@ -56,8 +56,9 @@ struct HMapHeader {
/// HashHMapKey - This is the 'well known' hash function required by the file
/// format, used to look up keys in the hash table. The hash table uses simple
/// linear probing based on this function.
-static inline unsigned HashHMapKey(const char *S, const char *End) {
+static inline unsigned HashHMapKey(llvm::StringRef Str) {
unsigned Result = 0;
+ const char *S = Str.begin(), *End = Str.end();
for (; S != End; S++)
Result += tolower(*S) * 13;
@@ -172,17 +173,6 @@ const char *HeaderMap::getString(unsigned StrTabIdx) const {
return FileBuffer->getBufferStart()+StrTabIdx;
}
-/// StringsEqualWithoutCase - Compare the specified two strings for case-
-/// insensitive equality, returning true if they are equal. Both strings are
-/// known to have the same length.
-static bool StringsEqualWithoutCase(const char *S1, const char *S2,
- unsigned Len) {
- for (; Len; ++S1, ++S2, --Len)
- if (tolower(*S1) != tolower(*S2))
- return false;
- return true;
-}
-
//===----------------------------------------------------------------------===//
// The Main Drivers
//===----------------------------------------------------------------------===//
@@ -209,8 +199,7 @@ void HeaderMap::dump() const {
/// LookupFile - Check to see if the specified relative filename is located in
/// this HeaderMap. If so, open it and return its FileEntry.
-const FileEntry *HeaderMap::LookupFile(const char *FilenameStart,
- const char *FilenameEnd,
+const FileEntry *HeaderMap::LookupFile(llvm::StringRef Filename,
FileManager &FM) const {
const HMapHeader &Hdr = getHeader();
unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
@@ -221,18 +210,12 @@ const FileEntry *HeaderMap::LookupFile(const char *FilenameStart,
return 0;
// Linearly probe the hash table.
- for (unsigned Bucket = HashHMapKey(FilenameStart, FilenameEnd);; ++Bucket) {
+ for (unsigned Bucket = HashHMapKey(Filename);; ++Bucket) {
HMapBucket B = getBucket(Bucket & (NumBuckets-1));
if (B.Key == HMAP_EmptyBucketKey) return 0; // Hash miss.
// See if the key matches. If not, probe on.
- const char *Key = getString(B.Key);
- unsigned BucketKeyLen = strlen(Key);
- if (BucketKeyLen != unsigned(FilenameEnd-FilenameStart))
- continue;
-
- // See if the actual strings equal.
- if (!StringsEqualWithoutCase(FilenameStart, Key, BucketKeyLen))
+ if (!Filename.equals_lower(getString(B.Key)))
continue;
// If so, we have a match in the hash table. Construct the destination