aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Check identity before comparing fields In immutable Thrift structs.
Date Tue, 18 Oct 2016 20:18:52 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 8c1200894 -> 485504a20


Check identity before comparing fields In immutable Thrift structs.

I saw THRIFT-3868 and thought we could apply the same micro-optimization
as well. Details: https://github.com/apache/thrift/pull/1106

Example of a generated equals method (in ITaskConfig):

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (!(o instanceof ITaskConfig)) {
        return false;
      }
      ITaskConfig other = (ITaskConfig) o;
      return Objects.equals(job, other.job)
          && Objects.equals(owner, other.owner)
          && Objects.equals(isService, other.isService)
          && Objects.equals(numCpus, other.numCpus)
          && Objects.equals(ramMb, other.ramMb)
          && Objects.equals(diskMb, other.diskMb)
          && Objects.equals(priority, other.priority)
          && Objects.equals(maxTaskFailures, other.maxTaskFailures)
          && Objects.equals(production, other.production)
          && Objects.equals(tier, other.tier)
          && Objects.equals(resources, other.resources)
          && Objects.equals(constraints, other.constraints)
          && Objects.equals(requestedPorts, other.requestedPorts)
          && Objects.equals(mesosFetcherUris, other.mesosFetcherUris)
          && Objects.equals(taskLinks, other.taskLinks)
          && Objects.equals(contactEmail, other.contactEmail)
          && Objects.equals(executorConfig, other.executorConfig)
          && Objects.equals(metadata, other.metadata)
          && Objects.equals(container, other.container);
    }

Reviewed at https://reviews.apache.org/r/52921/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/485504a2
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/485504a2
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/485504a2

Branch: refs/heads/master
Commit: 485504a205d6cc1f17a115d41290dde49942dade
Parents: 8c12008
Author: Stephan Erb <serb@apache.org>
Authored: Tue Oct 18 22:18:32 2016 +0200
Committer: Stephan Erb <serb@apache.org>
Committed: Tue Oct 18 22:18:32 2016 +0200

----------------------------------------------------------------------
 .../python/apache/aurora/tools/java/thrift_wrapper_codegen.py     | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/485504a2/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py b/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
index 7c28180..1efef2d 100644
--- a/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
+++ b/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
@@ -218,6 +218,9 @@ public final class %(name)s {
 
   @Override
   public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
     if (!(o instanceof %(name)s)) {
       return false;
     }


Mime
View raw message