summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-10 01:35:12 +0000
committerChris Lattner <sabre@nondot.org>2010-01-10 01:35:12 +0000
commitd081f8c851d5ea15456b9e56a88cd3fc11a26f77 (patch)
tree732f29aeb5552a70c2014af3368364e0c3670fc5 /clang/lib/Lex/HeaderMap.cpp
parent321098ebec22e9b93da4b14490881c2cfc285092 (diff)
downloadbcm5719-llvm-d081f8c851d5ea15456b9e56a88cd3fc11a26f77.tar.gz
bcm5719-llvm-d081f8c851d5ea15456b9e56a88cd3fc11a26f77.zip
stringref'ize a bunch of filename handling logic. Much
nicer than passing around two const char*'s. llvm-svn: 93094
Diffstat (limited to 'clang/lib/Lex/HeaderMap.cpp')
-rw-r--r--clang/lib/Lex/HeaderMap.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index df712760bb2..20de65f91f4 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/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;
@@ -209,8 +210,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 +221,18 @@ 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))
+ if (BucketKeyLen != unsigned(Filename.size()))
continue;
// See if the actual strings equal.
- if (!StringsEqualWithoutCase(FilenameStart, Key, BucketKeyLen))
+ if (!StringsEqualWithoutCase(Filename.begin(), Key, BucketKeyLen))
continue;
// If so, we have a match in the hash table. Construct the destination
OpenPOWER on IntegriCloud