István Fajth created HDDS-6439:
----------------------------------

             Summary: Minor perf optimization in the version enums
                 Key: HDDS-6439
                 URL: https://issues.apache.org/jira/browse/HDDS-6439
             Project: Apache Ozone
          Issue Type: Sub-task
            Reporter: István Fajth
            Assignee: István Fajth


To avoid using values() all the time when the version is read from proto a 
minor optimization was suggested in HDDS-6391, this JIRA is to track this.

The suggestion:

{code}
  private static final Map<Integer, DatanodeVersion> BY_PROTO_VALUE =
      Arrays.stream(DatanodeVersion.values())
        .collect(toMap(DatanodeVersion::toProtoValue, identity()));

  public static DatanodeVersion fromProtoValue(int value) {
    return BY_PROTO_VALUE.getOrDefault(value, FUTURE_VERSION);
  }
{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to