8004661: Comment and function name java_lang_String::toHash is wrong

Renamed to hash_code

Reviewed-by: dholmes, coleenp, brutisso
This commit is contained in:
Erik Helin 2012-12-13 10:09:49 +01:00 committed by Bengt Rutisson
parent 1dff0005b9
commit 0ed52d16e2
3 changed files with 9 additions and 9 deletions

View File

@ -327,14 +327,14 @@ jchar* java_lang_String::as_unicode_string(oop java_string, int& length) {
return result;
}
unsigned int java_lang_String::to_hash(oop java_string) {
unsigned int java_lang_String::hash_code(oop java_string) {
int length = java_lang_String::length(java_string);
// Zero length string will hash to zero with String.toHash() function.
// Zero length string will hash to zero with String.hashCode() function.
if (length == 0) return 0;
typeArrayOop value = java_lang_String::value(java_string);
int offset = java_lang_String::offset(java_string);
return java_lang_String::to_hash(value->char_at_addr(offset), length);
return java_lang_String::hash_code(value->char_at_addr(offset), length);
}
char* java_lang_String::as_quoted_ascii(oop java_string) {

View File

@ -166,8 +166,8 @@ class java_lang_String : AllStatic {
// objects in the shared archive file.
// hash P(31) from Kernighan & Ritchie
//
// For this reason, THIS ALGORITHM MUST MATCH String.toHash().
template <typename T> static unsigned int to_hash(T* s, int len) {
// For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
template <typename T> static unsigned int hash_code(T* s, int len) {
unsigned int h = 0;
while (len-- > 0) {
h = 31*h + (unsigned int) *s;
@ -175,10 +175,10 @@ class java_lang_String : AllStatic {
}
return h;
}
static unsigned int to_hash(oop java_string);
static unsigned int hash_code(oop java_string);
// This is the string hash code used by the StringTable, which may be
// the same as String.toHash or an alternate hash code.
// the same as String.hashCode or an alternate hash code.
static unsigned int hash_string(oop java_string);
static bool equals(oop java_string, jchar* chars, int len);

View File

@ -179,7 +179,7 @@ Symbol* SymbolTable::lookup(int index, const char* name,
unsigned int SymbolTable::hash_symbol(const char* s, int len) {
return use_alternate_hashcode() ?
AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
java_lang_String::to_hash(s, len);
java_lang_String::hash_code(s, len);
}
@ -617,7 +617,7 @@ bool StringTable::_needs_rehashing = false;
// Pick hashing algorithm
unsigned int StringTable::hash_string(const jchar* s, int len) {
return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
java_lang_String::to_hash(s, len);
java_lang_String::hash_code(s, len);
}
oop StringTable::lookup(int index, jchar* name,