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:
committed by
waddlesplash
parent
f589347ebc
commit
6a2d53e723
@@ -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 "StackTrace.h"
|
||||||
#include "StackFrame.h"
|
#include "StackFrame.h"
|
||||||
#include "StackFrameValues.h"
|
#include "StackFrameValues.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "StringValue.h"
|
#include "StringValue.h"
|
||||||
#include "SyntheticPrimitiveType.h"
|
#include "SyntheticPrimitiveType.h"
|
||||||
#include "TableCellValueEditor.h"
|
#include "TableCellValueEditor.h"
|
||||||
@@ -245,7 +244,7 @@ protected:
|
|||||||
virtual uint32 ComputeHashValue() const
|
virtual uint32 ComputeHashValue() const
|
||||||
{
|
{
|
||||||
uint32 hash = reinterpret_cast<addr_t>(fInfo);
|
uint32 hash = reinterpret_cast<addr_t>(fInfo);
|
||||||
hash = hash * 19 + StringUtils::HashValue(fInfo->Expression());
|
hash = hash * 19 + fInfo->Expression().HashValue();
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ local sources =
|
|||||||
BitBuffer.cpp
|
BitBuffer.cpp
|
||||||
IntegerFormatter.cpp
|
IntegerFormatter.cpp
|
||||||
RangeList.cpp
|
RangeList.cpp
|
||||||
StringUtils.cpp
|
|
||||||
Worker.cpp
|
Worker.cpp
|
||||||
|
|
||||||
# value
|
# value
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#include "SourceFile.h"
|
#include "SourceFile.h"
|
||||||
#include "StackFrame.h"
|
#include "StackFrame.h"
|
||||||
#include "Statement.h"
|
#include "Statement.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "SymbolInfo.h"
|
#include "SymbolInfo.h"
|
||||||
#include "TargetAddressRangeList.h"
|
#include "TargetAddressRangeList.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
@@ -247,7 +246,7 @@ struct DwarfImageDebugInfo::TypeNameKey {
|
|||||||
|
|
||||||
uint32 HashValue() const
|
uint32 HashValue() const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(typeName);
|
return typeName.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const TypeNameKey& other) const
|
bool operator==(const TypeNameKey& other) const
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include "Register.h"
|
#include "Register.h"
|
||||||
#include "RegisterMap.h"
|
#include "RegisterMap.h"
|
||||||
#include "ReturnValueID.h"
|
#include "ReturnValueID.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "Tracing.h"
|
#include "Tracing.h"
|
||||||
#include "ValueLocation.h"
|
#include "ValueLocation.h"
|
||||||
#include "Variable.h"
|
#include "Variable.h"
|
||||||
@@ -63,7 +62,7 @@ protected:
|
|||||||
virtual uint32 ComputeHashValue() const
|
virtual uint32 ComputeHashValue() const
|
||||||
{
|
{
|
||||||
uint32 hash = fFunctionID->HashValue();
|
uint32 hash = fFunctionID->HashValue();
|
||||||
return hash * 19 + StringUtils::HashValue(fName);
|
return hash * 19 + fName.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -106,7 +105,7 @@ protected:
|
|||||||
virtual uint32 ComputeHashValue() const
|
virtual uint32 ComputeHashValue() const
|
||||||
{
|
{
|
||||||
uint32 hash = fFunctionID->HashValue();
|
uint32 hash = fFunctionID->HashValue();
|
||||||
hash = hash * 19 + StringUtils::HashValue(fName);
|
hash = hash * 19 + fName.HashValue();
|
||||||
hash = hash * 19 + fLine;
|
hash = hash * 19 + fLine;
|
||||||
hash = hash * 19 + fColumn;
|
hash = hash * 19 + fColumn;
|
||||||
return hash;
|
return hash;
|
||||||
@@ -152,7 +151,7 @@ protected:
|
|||||||
virtual uint32 ComputeHashValue() const
|
virtual uint32 ComputeHashValue() const
|
||||||
{
|
{
|
||||||
uint32 hash = fFunctionID->HashValue();
|
uint32 hash = fFunctionID->HashValue();
|
||||||
return hash * 25 + StringUtils::HashValue(fName);
|
return hash * 25 + fName.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include <AutoLocker.h>
|
#include <AutoLocker.h>
|
||||||
|
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
#include "TypeLookupConstraints.h"
|
#include "TypeLookupConstraints.h"
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ struct GlobalTypeCache::TypeEntryHashDefinitionByName {
|
|||||||
|
|
||||||
size_t HashKey(const BString& key) const
|
size_t HashKey(const BString& key) const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(key);
|
return key.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Hash(const TypeEntry* value) const
|
size_t Hash(const TypeEntry* value) const
|
||||||
@@ -68,7 +67,7 @@ struct GlobalTypeCache::TypeEntryHashDefinitionByID {
|
|||||||
|
|
||||||
size_t HashKey(const BString& key) const
|
size_t HashKey(const BString& key) const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(key);
|
return key.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Hash(const TypeEntry* value) const
|
size_t Hash(const TypeEntry* value) const
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "SourceFile.h"
|
#include "SourceFile.h"
|
||||||
#include "SourceLanguage.h"
|
#include "SourceLanguage.h"
|
||||||
#include "SpecificImageDebugInfo.h"
|
#include "SpecificImageDebugInfo.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
#include "TypeLookupConstraints.h"
|
#include "TypeLookupConstraints.h"
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ struct TeamDebugInfo::FunctionHashDefinition {
|
|||||||
if (key->SourceFile() == NULL)
|
if (key->SourceFile() == NULL)
|
||||||
return (uint32)(addr_t)key;
|
return (uint32)(addr_t)key;
|
||||||
|
|
||||||
uint32 hash = StringUtils::HashValue(key->Name());
|
uint32 hash = key->Name().HashValue();
|
||||||
hash = hash * 17 + (uint32)(addr_t)key->SourceFile();
|
hash = hash * 17 + (uint32)(addr_t)key->SourceFile();
|
||||||
SourceLocation location = key->GetSourceLocation();
|
SourceLocation location = key->GetSourceLocation();
|
||||||
hash = hash * 17 + location.Line();
|
hash = hash * 17 + location.Line();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "LocatableDirectory.h"
|
#include "LocatableDirectory.h"
|
||||||
#include "LocatableFile.h"
|
#include "LocatableFile.h"
|
||||||
#include "SourceFile.h"
|
#include "SourceFile.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "TeamFileManagerSettings.h"
|
#include "TeamFileManagerSettings.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -58,8 +57,8 @@ struct FileManager::EntryPath {
|
|||||||
|
|
||||||
size_t HashValue() const
|
size_t HashValue() const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(directory)
|
return BString::HashValue(directory)
|
||||||
^ StringUtils::HashValue(name);
|
^ BString::HashValue(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const EntryPath& other) const
|
bool operator==(const EntryPath& other) const
|
||||||
@@ -519,7 +518,7 @@ struct FileManager::SourceFileHashDefinition {
|
|||||||
|
|
||||||
size_t HashKey(const BString& key) const
|
size_t HashKey(const BString& key) const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(key);
|
return key.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Hash(const SourceFileEntry* value) const
|
size_t Hash(const SourceFileEntry* value) const
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
#include "StringUtils.h"
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - FunctionID
|
// #pragma mark - FunctionID
|
||||||
|
|
||||||
@@ -55,8 +53,8 @@ FunctionID::Archive(BMessage* archive, bool deep) const
|
|||||||
uint32
|
uint32
|
||||||
FunctionID::ComputeHashValue() const
|
FunctionID::ComputeHashValue() const
|
||||||
{
|
{
|
||||||
return StringUtils::HashValue(fPath) * 17
|
return fPath.HashValue() * 17
|
||||||
+ StringUtils::HashValue(fFunctionName);
|
+ fFunctionName.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "FunctionID.h"
|
#include "FunctionID.h"
|
||||||
#include "model/Thread.h"
|
#include "model/Thread.h"
|
||||||
#include "StringUtils.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct ExpressionValues::Key {
|
struct ExpressionValues::Key {
|
||||||
@@ -30,7 +29,7 @@ struct ExpressionValues::Key {
|
|||||||
uint32 HashValue() const
|
uint32 HashValue() const
|
||||||
{
|
{
|
||||||
return function->HashValue() ^ thread->ID()
|
return function->HashValue() ^ thread->ID()
|
||||||
^ StringUtils::HashValue(expression);
|
^ expression.HashValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Key& other) const
|
bool operator==(const Key& other) const
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "StringUtils.h"
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - TypeComponent
|
// #pragma mark - TypeComponent
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ uint32
|
|||||||
TypeComponent::HashValue() const
|
TypeComponent::HashValue() const
|
||||||
{
|
{
|
||||||
uint32 hash = ((uint32)index << 8) | (componentKind << 4) | typeKind;
|
uint32 hash = ((uint32)index << 8) | (componentKind << 4) | typeKind;
|
||||||
return StringUtils::HashValue(name) * 13 + hash;
|
return name.HashValue() * 13 + hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user