Debugger: Use BString::HashValue().

Previously BString::HashValue() had an identical hash to the one
in StringUtils::HashValue(), but now it uses hashdjb2, so this
means Debugger will now use that also.

Tested basic Debugger functionality, seems to still work.

Change-Id: Ia341daa56249967a494df46e6e0a69a74c8b5fe2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8266
Reviewed-by: Rene Gollent <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-09-09 18:13:29 +00:00
committed by waddlesplash
parent f589347ebc
commit 6a2d53e723
12 changed files with 15 additions and 78 deletions
@@ -1,25 +0,0 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected]. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
#include <String.h>
class StringUtils {
public:
static uint32 HashValue(const char* string);
static uint32 HashValue(const BString& string);
};
/*static*/ inline uint32
StringUtils::HashValue(const BString& string)
{
return HashValue(string.String());
}
#endif // STRING_UTILS_H
@@ -42,7 +42,6 @@
#include "StackTrace.h"
#include "StackFrame.h"
#include "StackFrameValues.h"
#include "StringUtils.h"
#include "StringValue.h"
#include "SyntheticPrimitiveType.h"
#include "TableCellValueEditor.h"
@@ -245,7 +244,7 @@ protected:
virtual uint32 ComputeHashValue() const
{
uint32 hash = reinterpret_cast<addr_t>(fInfo);
hash = hash * 19 + StringUtils::HashValue(fInfo->Expression());
hash = hash * 19 + fInfo->Expression().HashValue();
return hash;
}
-1
View File
@@ -285,7 +285,6 @@ local sources =
BitBuffer.cpp
IntegerFormatter.cpp
RangeList.cpp
StringUtils.cpp
Worker.cpp
# value
@@ -50,7 +50,6 @@
#include "SourceFile.h"
#include "StackFrame.h"
#include "Statement.h"
#include "StringUtils.h"
#include "SymbolInfo.h"
#include "TargetAddressRangeList.h"
#include "Team.h"
@@ -247,7 +246,7 @@ struct DwarfImageDebugInfo::TypeNameKey {
uint32 HashValue() const
{
return StringUtils::HashValue(typeName);
return typeName.HashValue();
}
bool operator==(const TypeNameKey& other) const
@@ -26,7 +26,6 @@
#include "Register.h"
#include "RegisterMap.h"
#include "ReturnValueID.h"
#include "StringUtils.h"
#include "Tracing.h"
#include "ValueLocation.h"
#include "Variable.h"
@@ -63,7 +62,7 @@ protected:
virtual uint32 ComputeHashValue() const
{
uint32 hash = fFunctionID->HashValue();
return hash * 19 + StringUtils::HashValue(fName);
return hash * 19 + fName.HashValue();
}
private:
@@ -106,7 +105,7 @@ protected:
virtual uint32 ComputeHashValue() const
{
uint32 hash = fFunctionID->HashValue();
hash = hash * 19 + StringUtils::HashValue(fName);
hash = hash * 19 + fName.HashValue();
hash = hash * 19 + fLine;
hash = hash * 19 + fColumn;
return hash;
@@ -152,7 +151,7 @@ protected:
virtual uint32 ComputeHashValue() const
{
uint32 hash = fFunctionID->HashValue();
return hash * 25 + StringUtils::HashValue(fName);
return hash * 25 + fName.HashValue();
}
private:
@@ -12,7 +12,6 @@
#include <AutoLocker.h>
#include "StringUtils.h"
#include "Type.h"
#include "TypeLookupConstraints.h"
@@ -42,7 +41,7 @@ struct GlobalTypeCache::TypeEntryHashDefinitionByName {
size_t HashKey(const BString& key) const
{
return StringUtils::HashValue(key);
return key.HashValue();
}
size_t Hash(const TypeEntry* value) const
@@ -68,7 +67,7 @@ struct GlobalTypeCache::TypeEntryHashDefinitionByID {
size_t HashKey(const BString& key) const
{
return StringUtils::HashValue(key);
return key.HashValue();
}
size_t Hash(const TypeEntry* value) const
@@ -29,7 +29,6 @@
#include "SourceFile.h"
#include "SourceLanguage.h"
#include "SpecificImageDebugInfo.h"
#include "StringUtils.h"
#include "Type.h"
#include "TypeLookupConstraints.h"
@@ -47,7 +46,7 @@ struct TeamDebugInfo::FunctionHashDefinition {
if (key->SourceFile() == NULL)
return (uint32)(addr_t)key;
uint32 hash = StringUtils::HashValue(key->Name());
uint32 hash = key->Name().HashValue();
hash = hash * 17 + (uint32)(addr_t)key->SourceFile();
SourceLocation location = key->GetSourceLocation();
hash = hash * 17 + location.Line();
+3 -4
View File
@@ -14,7 +14,6 @@
#include "LocatableDirectory.h"
#include "LocatableFile.h"
#include "SourceFile.h"
#include "StringUtils.h"
#include "TeamFileManagerSettings.h"
@@ -58,8 +57,8 @@ struct FileManager::EntryPath {
size_t HashValue() const
{
return StringUtils::HashValue(directory)
^ StringUtils::HashValue(name);
return BString::HashValue(directory)
^ BString::HashValue(name);
}
bool operator==(const EntryPath& other) const
@@ -519,7 +518,7 @@ struct FileManager::SourceFileHashDefinition {
size_t HashKey(const BString& key) const
{
return StringUtils::HashValue(key);
return key.HashValue();
}
size_t Hash(const SourceFileEntry* value) const
+2 -4
View File
@@ -10,8 +10,6 @@
#include <Message.h>
#include "StringUtils.h"
// #pragma mark - FunctionID
@@ -55,8 +53,8 @@ FunctionID::Archive(BMessage* archive, bool deep) const
uint32
FunctionID::ComputeHashValue() const
{
return StringUtils::HashValue(fPath) * 17
+ StringUtils::HashValue(fFunctionName);
return fPath.HashValue() * 17
+ fFunctionName.HashValue();
}
+1 -2
View File
@@ -11,7 +11,6 @@
#include "FunctionID.h"
#include "model/Thread.h"
#include "StringUtils.h"
struct ExpressionValues::Key {
@@ -30,7 +29,7 @@ struct ExpressionValues::Key {
uint32 HashValue() const
{
return function->HashValue() ^ thread->ID()
^ StringUtils::HashValue(expression);
^ expression.HashValue();
}
bool operator==(const Key& other) const
@@ -10,8 +10,6 @@
#include <new>
#include "StringUtils.h"
// #pragma mark - TypeComponent
@@ -32,7 +30,7 @@ uint32
TypeComponent::HashValue() const
{
uint32 hash = ((uint32)index << 8) | (componentKind << 4) | typeKind;
return StringUtils::HashValue(name) * 13 + hash;
return name.HashValue() * 13 + hash;
}
-26
View File
@@ -1,26 +0,0 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#include "StringUtils.h"
// from the Dragon Book: a slightly modified hashpjw()
/*static*/ uint32
StringUtils::HashValue(const char* string)
{
if (string == NULL)
return 0;
uint32 h = 0;
for (; *string; string++) {
uint32 g = h & 0xf0000000;
if (g)
h ^= g >> 24;
h = (h << 4) + *string;
}
return h;
}