Fixes for Symtab.cpp to take advantage of the new unique C string map

changes that were just submitted.

llvm-svn: 139478
This commit is contained in:
Greg Clayton 2011-09-11 00:20:09 +00:00
parent c0a87652ba
commit 38e953dda2
3 changed files with 26 additions and 65 deletions

View File

@ -37,7 +37,11 @@ public:
/// ///
/// Initializes the string to an empty string. /// Initializes the string to an empty string.
//------------------------------------------------------------------ //------------------------------------------------------------------
ConstString (); ConstString ():
m_string (NULL)
{
}
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Copy constructor /// Copy constructor
@ -48,7 +52,10 @@ public:
/// @param[in] rhs /// @param[in] rhs
/// Another string object to copy. /// Another string object to copy.
//------------------------------------------------------------------ //------------------------------------------------------------------
ConstString (const ConstString& rhs); ConstString (const ConstString& rhs) :
m_string (rhs.m_string)
{
}
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Construct with C String value /// Construct with C String value
@ -99,7 +106,10 @@ public:
/// greater than zero, the string will remain in the string pool /// greater than zero, the string will remain in the string pool
/// until the last reference is released by other ConstString objects. /// until the last reference is released by other ConstString objects.
//------------------------------------------------------------------ //------------------------------------------------------------------
~ConstString (); ~ConstString ()
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
/// C string equality function object for CStrings contains in the /// C string equality function object for CStrings contains in the
@ -405,7 +415,11 @@ public:
/// @see ConstString::StaticMemorySize () /// @see ConstString::StaticMemorySize ()
//------------------------------------------------------------------ //------------------------------------------------------------------
size_t size_t
MemorySize () const; MemorySize () const
{
return sizeof(ConstString);
}
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Get the size in bytes of the current global string pool. /// Get the size in bytes of the current global string pool.

View File

@ -190,27 +190,6 @@ StringPool()
return string_pool; return string_pool;
} }
//----------------------------------------------------------------------
// Default constructor
//
// Initializes the string to an empty string.
//----------------------------------------------------------------------
ConstString::ConstString () :
m_string (NULL)
{
}
//----------------------------------------------------------------------
// Copy constructor
//
// Copies the string value in "rhs" and retains an extra reference
// to the string value in the string pool.
//----------------------------------------------------------------------
ConstString::ConstString (const ConstString& rhs) :
m_string (rhs.m_string)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Construct with C String value // Construct with C String value
// //
@ -244,18 +223,6 @@ ConstString::ConstString (const char *cstr, size_t cstr_len) :
{ {
} }
//----------------------------------------------------------------------
// Destructor
//
// Decrements the reference count on the contained string, and if
// the resulting reference count is zero, then the string is removed
// from the string pool. If the reference count is still greater
// than zero, the string will remain in the string pool
//----------------------------------------------------------------------
ConstString::~ConstString ()
{
}
bool bool
ConstString::operator < (const ConstString& rhs) const ConstString::operator < (const ConstString& rhs) const
{ {
@ -401,17 +368,6 @@ ConstString::SetTrimmedCStringWithLength (const char *cstr, size_t cstr_len)
m_string = StringPool().GetConstTrimmedCStringWithLength (cstr, cstr_len); m_string = StringPool().GetConstTrimmedCStringWithLength (cstr, cstr_len);
} }
//----------------------------------------------------------------------
// Return the size in bytes that this object takes in memory. The
// resulting size will not include any of the C string values from
// the global string pool (see StaticMemorySize ()).
//----------------------------------------------------------------------
size_t
ConstString::MemorySize() const
{
return sizeof(ConstString);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Reports the the size in bytes of all shared C string values, // Reports the the size in bytes of all shared C string values,
// containers and reference count values as a byte size for the // containers and reference count values as a byte size for the

View File

@ -462,20 +462,11 @@ Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
if (symbol_name) if (symbol_name)
{ {
const size_t old_size = indexes.size(); const char *symbol_cstr = symbol_name.GetCString();
if (!m_name_indexes_computed) if (!m_name_indexes_computed)
InitNameIndexes(); InitNameIndexes();
const char *symbol_cstr = symbol_name.GetCString(); return m_name_to_index.GetValues (symbol_cstr, indexes);
const UniqueCStringMap<uint32_t>::Entry *entry_ptr;
for (entry_ptr = m_name_to_index.FindFirstValueForName (symbol_cstr);
entry_ptr!= NULL;
entry_ptr = m_name_to_index.FindNextValueForName (symbol_cstr, entry_ptr))
{
indexes.push_back (entry_ptr->value);
}
return indexes.size() - old_size;
} }
return 0; return 0;
} }
@ -493,13 +484,13 @@ Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbo
InitNameIndexes(); InitNameIndexes();
const char *symbol_cstr = symbol_name.GetCString(); const char *symbol_cstr = symbol_name.GetCString();
const UniqueCStringMap<uint32_t>::Entry *entry_ptr;
for (entry_ptr = m_name_to_index.FindFirstValueForName (symbol_cstr); std::vector<uint32_t> all_name_indexes;
entry_ptr!= NULL; const size_t name_match_count = m_name_to_index.GetValues (symbol_cstr, all_name_indexes);
entry_ptr = m_name_to_index.FindNextValueForName (symbol_cstr, entry_ptr)) for (size_t i=0; i<name_match_count; ++i)
{ {
if (CheckSymbolAtIndex(entry_ptr->value, symbol_debug_type, symbol_visibility)) if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type, symbol_visibility))
indexes.push_back (entry_ptr->value); indexes.push_back (all_name_indexes[i]);
} }
return indexes.size() - old_size; return indexes.size() - old_size;
} }