mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8332249: Micro-optimize Method.hashCode
Reviewed-by: liach
This commit is contained in:
parent
4957145e6c
commit
8ba9bc6f17
2 changed files with 20 additions and 3 deletions
|
@ -95,6 +95,8 @@ public final class Method extends Executable {
|
|||
// If this branching structure would ever contain cycles, deadlocks can
|
||||
// occur in annotation code.
|
||||
private Method root;
|
||||
// Hash code of this object
|
||||
private int hash;
|
||||
|
||||
// Generics infrastructure
|
||||
private String getGenericSignature() {return signature;}
|
||||
|
@ -381,7 +383,13 @@ public final class Method extends Executable {
|
|||
* method's declaring class name and the method's name.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
|
||||
int hc = hash;
|
||||
|
||||
if (hc == 0) {
|
||||
hc = hash = getDeclaringClass().getName().hashCode() ^ getName()
|
||||
.hashCode();
|
||||
}
|
||||
return hc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue