dasahcc commented on a change in pull request #1043:
URL: https://github.com/apache/helix/pull/1043#discussion_r434979363



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/topology/Topology.java
##########
@@ -55,16 +55,10 @@
   private final List<String> _liveInstances;
   private final Map<String, InstanceConfig> _instanceConfigMap;
   private final ClusterConfig _clusterConfig;
-  private final boolean _topologyAwareEnabled;
+  private static final String DEFAULT_PATH_PREFIX = "Helix_default_";

Review comment:
       Helix usually have all capitalized strings as our naming convention. Is 
this newly introduced or exists before?

##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/topology/Topology.java
##########
@@ -81,62 +75,42 @@ public Topology(final List<String> allNodes, final 
List<String> liveNodes,
       throw new HelixException(String.format("Config for instances %s is not 
found!",
           _allInstances.removeAll(_instanceConfigMap.keySet())));
     }
-
     _clusterConfig = clusterConfig;
-    _types = new LinkedHashSet<>();
-    _topologyAwareEnabled = clusterConfig.isTopologyAwareEnabled();
 
-    if (_topologyAwareEnabled) {
+    if (clusterConfig.isTopologyAwareEnabled()) {
       String topologyDef = _clusterConfig.getTopology();
       if (topologyDef != null) {
         // Customized cluster topology definition is configured.
-        String[] types = topologyDef.trim().split("/");
-        for (int i = 0; i < types.length; i++) {
-          if (types[i].length() != 0) {
-            _types.add(types[i]);
+        String[] topologyStr = topologyDef.trim().split("/");
+        int lastValidTypeIdx = topologyStr.length - 1;
+        for (; lastValidTypeIdx >= 0; --lastValidTypeIdx) {

Review comment:
       Why not change this to be while clause since this already lost advantage 
of for loop for instantiation.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to