[llvm-commits] CVS: llvm/lib/Support/CStringMap.cpp
Chris Lattner
sabre at nondot.org
Thu Feb 8 11:08:56 PST 2007
Changes in directory llvm/lib/Support:
CStringMap.cpp updated: 1.3 -> 1.4
---
Log message:
Allow cstringmap to contain strings with nul characters in them.
---
Diffs of the changes: (+5 -4)
CStringMap.cpp | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
Index: llvm/lib/Support/CStringMap.cpp
diff -u llvm/lib/Support/CStringMap.cpp:1.3 llvm/lib/Support/CStringMap.cpp:1.4
--- llvm/lib/Support/CStringMap.cpp:1.3 Sat Jan 6 17:20:51 2007
+++ llvm/lib/Support/CStringMap.cpp Thu Feb 8 13:08:37 2007
@@ -58,7 +58,7 @@
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 @@
// 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 @@
/// 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);
}
}
More information about the llvm-commits
mailing list