comparison src/share/vm/classfile/javaClasses.hpp @ 7399:2aa953165ade

8004661: Comment and function name java_lang_String::toHash is wrong Summary: renamed to hash_code Reviewed-by: dholmes, coleenp, brutisso Contributed-by: erik.helin@oracle.com
author brutisso
date Thu, 13 Dec 2012 10:09:49 +0100
parents 90273fc0a981
children 4daebd4cc1dd
comparison
equal deleted inserted replaced
7398:a14c5698a162 7399:2aa953165ade
164 // String.hashCode(). This value is normally calculated in Java code 164 // String.hashCode(). This value is normally calculated in Java code
165 // in the String.hashCode method(), but is precomputed for String 165 // in the String.hashCode method(), but is precomputed for String
166 // objects in the shared archive file. 166 // objects in the shared archive file.
167 // hash P(31) from Kernighan & Ritchie 167 // hash P(31) from Kernighan & Ritchie
168 // 168 //
169 // For this reason, THIS ALGORITHM MUST MATCH String.toHash(). 169 // For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
170 template <typename T> static unsigned int to_hash(T* s, int len) { 170 template <typename T> static unsigned int hash_code(T* s, int len) {
171 unsigned int h = 0; 171 unsigned int h = 0;
172 while (len-- > 0) { 172 while (len-- > 0) {
173 h = 31*h + (unsigned int) *s; 173 h = 31*h + (unsigned int) *s;
174 s++; 174 s++;
175 } 175 }
176 return h; 176 return h;
177 } 177 }
178 static unsigned int to_hash(oop java_string); 178 static unsigned int hash_code(oop java_string);
179 179
180 // This is the string hash code used by the StringTable, which may be 180 // This is the string hash code used by the StringTable, which may be
181 // the same as String.toHash or an alternate hash code. 181 // the same as String.hashCode or an alternate hash code.
182 static unsigned int hash_string(oop java_string); 182 static unsigned int hash_string(oop java_string);
183 183
184 static bool equals(oop java_string, jchar* chars, int len); 184 static bool equals(oop java_string, jchar* chars, int len);
185 185
186 // Conversion between '.' and '/' formats 186 // Conversion between '.' and '/' formats