aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/StringMap.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-08 19:08:37 +0000
committerChris Lattner <sabre@nondot.org>2007-02-08 19:08:37 +0000
commitee182422ff0b638b17c5ee802c19b8680107c2bb (patch)
tree69cad132da9557161604b1db2c59712e83a2b93c /lib/Support/StringMap.cpp
parent98a030c4680b984a06abf79273873295c7634cd7 (diff)
Allow cstringmap to contain strings with nul characters in them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/StringMap.cpp')
-rw-r--r--lib/Support/StringMap.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Support/StringMap.cpp b/lib/Support/StringMap.cpp
index 31b50d2f15..b145e2ef81 100644
--- a/lib/Support/StringMap.cpp
+++ b/lib/Support/StringMap.cpp
@@ -58,7 +58,7 @@ unsigned CStringMapImpl::LookupBucketFor(const char *NameStart,
unsigned ProbeAmt = 1;
while (1) {
ItemBucket &Bucket = TheTable[BucketNo];
- void *BucketItem = Bucket.Item;
+ StringMapEntryBase *BucketItem = Bucket.Item;
// If we found an empty bucket, this key isn't in the table yet, return it.
if (BucketItem == 0) {
Bucket.FullHashValue = FullHashValue;
@@ -73,8 +73,9 @@ unsigned CStringMapImpl::LookupBucketFor(const char *NameStart,
// Do the comparison like this because NameStart isn't necessarily
// null-terminated!
char *ItemStr = (char*)BucketItem+ItemSize;
- if (strlen(ItemStr) == unsigned(NameEnd-NameStart) &&
- memcmp(ItemStr, NameStart, (NameEnd-NameStart)) == 0) {
+ unsigned ItemStrLen = BucketItem->getKeyLength();
+ if (unsigned(NameEnd-NameStart) == ItemStrLen &&
+ memcmp(ItemStr, NameStart, ItemStrLen) == 0) {
// We found a match!
return BucketNo;
}
@@ -131,7 +132,7 @@ void CStringMapImpl::RehashTable() {
/// invoking Visitor.Visit for each of them.
void CStringMapImpl::VisitEntries(const CStringMapVisitor &Visitor) const {
for (ItemBucket *IB = TheTable, *E = TheTable+NumBuckets; IB != E; ++IB) {
- if (void *Id = IB->Item)
+ if (StringMapEntryBase *Id = IB->Item)
Visitor.Visit((char*)Id + ItemSize, Id);
}
}