Convert StringMap to using StringRef for its APIs.
[oota-llvm.git] / lib / VMCore / ValueSymbolTable.cpp
index 3a0c54ed723f630357d115c8ffcca1153433a92b..8d3514b47519133816adeb65201f2a4db88382c2 100644 (file)
@@ -33,7 +33,7 @@ ValueSymbolTable::~ValueSymbolTable() {
 // lookup a value - Returns null on failure...
 //
 Value *ValueSymbolTable::lookup(const std::string &Name) const {
-  const_iterator VI = vmap.find(&Name[0], &Name[Name.size()]);
+  const_iterator VI = vmap.find(Name);
   if (VI != vmap.end())                   // We found the symbol
     return VI->getValue();
   return 0;
@@ -41,7 +41,8 @@ Value *ValueSymbolTable::lookup(const std::string &Name) const {
 
 Value *ValueSymbolTable::lookup(const char *NameBegin,
                                 const char *NameEnd) const {
-  const_iterator VI = vmap.find(NameBegin, NameEnd);
+  // FIXME: ValueSymbolTable should move to a StringRef based API.
+  const_iterator VI = vmap.find(StringRef(NameBegin, NameEnd - NameBegin));
   if (VI != vmap.end())                   // We found the symbol
     return VI->getValue();
   return 0;
@@ -70,8 +71,9 @@ void ValueSymbolTable::reinsertValue(Value* V) {
     UniqueName.resize(BaseSize);
     UniqueName.append_uint_32(++LastUnique);
     // Try insert the vmap entry with this suffix.
-    ValueName &NewName = vmap.GetOrCreateValue(&UniqueName[0],
-                                               &UniqueName[UniqueName.size()]);
+    ValueName &NewName =
+      vmap.GetOrCreateValue(StringRef(UniqueName.data(),
+                                      UniqueName.size()));
     if (NewName.getValue() == 0) {
       // Newly inserted name.  Success!
       NewName.setValue(V);
@@ -94,7 +96,7 @@ void ValueSymbolTable::removeValueName(ValueName *V) {
 ValueName *ValueSymbolTable::createValueName(const char *NameStart,
                                              unsigned NameLen, Value *V) {
   // In the common case, the name is not already in the symbol table.
-  ValueName &Entry = vmap.GetOrCreateValue(NameStart, NameStart+NameLen);
+  ValueName &Entry = vmap.GetOrCreateValue(StringRef(NameStart, NameLen));
   if (Entry.getValue() == 0) {
     Entry.setValue(V);
     //DEBUG(DOUT << " Inserted value: " << Entry.getKeyData() << ": "
@@ -111,8 +113,9 @@ ValueName *ValueSymbolTable::createValueName(const char *NameStart,
     UniqueName.append_uint_32(++LastUnique);
     
     // Try insert the vmap entry with this suffix.
-    ValueName &NewName = vmap.GetOrCreateValue(&UniqueName[0],
-                                               &UniqueName[UniqueName.size()]);
+    ValueName &NewName =
+      vmap.GetOrCreateValue(StringRef(UniqueName.data(),
+                                      UniqueName.size()));
     if (NewName.getValue() == 0) {
       // Newly inserted name.  Success!
       NewName.setValue(V);