Skip to content

Commit

Permalink
Avoid constant hashcode
Browse files Browse the repository at this point in the history
It's correct for hashcode to be 0, but using hashcode that's
class-specific reduces collisions, should two such objects be used
together in a hash map.
  • Loading branch information
findepi committed Oct 7, 2021
1 parent b61542c commit 5bb9420
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean equals(Object o)
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public List<Node> getChildren()
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public boolean equals(Object obj)
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean equals(Object o)
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public List<Node> getChildren()
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public boolean equals(Object obj)
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static final class SingletonIdentityCacheKey
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
}

@Override
Expand Down

0 comments on commit 5bb9420

Please sign in to comment.