Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-create hash code of NodeIno #600

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/src/main/java/org/astraea/app/admin/NodeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ static NodeInfo of(int id, String host, int port) {

static NodeInfo of(int id, String host, int port, boolean isOffline) {
return new NodeInfo() {
// NodeInfo is used to be key of Map commonly, so creating hash can reduce the memory pressure
private final int hashCode = Objects.hash(id, host, port);

@Override
public String host() {
return host;
Expand All @@ -60,7 +63,7 @@ public int port() {

@Override
public int hashCode() {
return Objects.hash(id, host, port);
return hashCode;
}

@Override
Expand Down