From b39fca958d70c9682aaa8b87f58aa88449582cc8 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 23 Feb 2018 17:49:26 +0000 Subject: Replace HashStringUsingDJB with llvm::djbHash Summary: The llvm function is equivalent to this one. Where possible I tried to replace const char* with llvm::StringRef to avoid extra strlen computations. In most places, I was able to track the c string back to the ConstString it was created from. I also create a test that verifies we are able to lookup names with unicode characters, as a bug in the llvm compiler (it accidentally used a different hash function) meant this was not working until recently. This also removes the unused ExportTable class. Reviewers: aprantl, davide Subscribers: JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D43596 llvm-svn: 325927 --- lldb/source/Target/ObjCLanguageRuntime.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lldb/source/Target/ObjCLanguageRuntime.cpp') diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index d3cc7c019dc..e50167dcb58 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -23,6 +23,7 @@ #include "lldb/Utility/Timer.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/DJB.h" using namespace lldb; using namespace lldb_private; @@ -45,8 +46,7 @@ bool ObjCLanguageRuntime::AddClass(ObjCISA isa, if (isa != 0) { m_isa_to_descriptor[isa] = descriptor_sp; // class_name is assumed to be valid - m_hash_to_isa_map.insert( - std::make_pair(MappedHash::HashStringUsingDJB(class_name), isa)); + m_hash_to_isa_map.insert(std::make_pair(llvm::djbHash(class_name), isa)); return true; } return false; @@ -180,8 +180,7 @@ ObjCLanguageRuntime::GetDescriptorIterator(const ConstString &name) { } else { // Name hashes were provided, so use them to efficiently lookup name to // isa/descriptor - const uint32_t name_hash = - MappedHash::HashStringUsingDJB(name.GetCString()); + const uint32_t name_hash = llvm::djbHash(name.GetStringRef()); std::pair range = m_hash_to_isa_map.equal_range(name_hash); for (HashToISAIterator range_pos = range.first; range_pos != range.second; -- cgit v1.2.3