[Lldb-commits] [lldb] r106545 - /lldb/trunk/source/Core/ConstString.cpp

Benjamin Kramer benny.kra at googlemail.com
Tue Jun 22 08:28:34 PDT 2010


Author: d0k
Date: Tue Jun 22 10:28:34 2010
New Revision: 106545

URL: http://llvm.org/viewvc/llvm-project?rev=106545&view=rev
Log:
Reduce code duplication.

This also moves strlen out of the mutex scope.

Modified:
    lldb/trunk/source/Core/ConstString.cpp

Modified: lldb/trunk/source/Core/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConstString.cpp?rev=106545&r1=106544&r2=106545&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConstString.cpp (original)
+++ lldb/trunk/source/Core/ConstString.cpp Tue Jun 22 10:28:34 2010
@@ -73,15 +73,7 @@
     GetConstCString (const char *cstr)
     {
         if (cstr)
-        {
-            Mutex::Locker locker (m_mutex);
-            llvm::StringRef string_ref (cstr);
-            llvm::StringMapEntry<uint32_t>& entry = m_string_map.GetOrCreateValue (string_ref);
-            const char *ccstr = entry.getKeyData();
-            llvm::StringMapEntry<uint32_t>&reconstituted_entry = GetStringMapEntryFromKeyData (ccstr);
-            assert (&entry == &reconstituted_entry);
-            return ccstr;
-        }
+            return GetConstCStringWithLength (cstr, strlen (cstr));
         return NULL;
     }
 
@@ -106,14 +98,8 @@
     {
         if (cstr)
         {
-            Mutex::Locker locker (m_mutex);
-            int actual_cstr_len = strlen (cstr);
-            llvm::StringRef string_ref (cstr, std::min<int>(actual_cstr_len, cstr_len));
-            llvm::StringMapEntry<uint32_t>& entry = m_string_map.GetOrCreateValue (string_ref);
-            const char *ccstr = entry.getKeyData();
-            llvm::StringMapEntry<uint32_t>&reconstituted_entry = GetStringMapEntryFromKeyData (ccstr);
-            assert (&entry == &reconstituted_entry);
-            return ccstr;
+            int trimmed_len = std::min<int> (strlen (cstr), cstr_len);
+            return GetConstCStringWithLength (cstr, trimmed_len);
         }
         return NULL;
     }





More information about the lldb-commits mailing list