You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ss...@apache.org on 2013/07/30 02:43:41 UTC

[2/2] git commit: Search frameworks & executors successively to save concat

Search frameworks & executors successively to save concat

Array.concat creates a new Array, which in this case is used once to
find frameworks and executors and then thrown away. Instead the Arrays
can be searched successively in place without allocating more memory.

Review: http://reviews.apache.org/r/13002


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5be5090a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5be5090a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5be5090a

Branch: refs/heads/master
Commit: 5be5090acfc5b14b6a9e1dc178720743bf0326dc
Parents: 834e365
Author: Ross Allen <re...@gmail.com>
Authored: Sat Jul 27 16:04:36 2013 -0700
Committer: Ross Allen <re...@gmail.com>
Committed: Mon Jul 29 17:43:24 2013 -0700

----------------------------------------------------------------------
 src/webui/master/static/js/controllers.js | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5be5090a/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js
index b9099e0..c553e35 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -683,11 +683,14 @@
 
         $scope.slave = {};
 
+        function matchFramework(framework) {
+          return $scope.framework_id === framework.id;
+        }
+
         // Find the framework; it's either active or completed.
-        $scope.framework = _.find($scope.state.frameworks.concat($scope.state.completed_frameworks),
-            function(framework) {
-              return $scope.framework_id === framework.id;
-            });
+        $scope.framework =
+          _.find($scope.state.frameworks, matchFramework) ||
+          _.find($scope.state.completed_frameworks, matchFramework);
 
         if (!$scope.framework) {
           $scope.alert_message = 'No framework found with ID: ' + $routeParams.framework_id;
@@ -695,11 +698,14 @@
           return;
         }
 
+        function matchExecutor(executor) {
+          return $scope.executor_id === executor.id;
+        }
+
         // Look for the executor; it's either active or completed.
-        $scope.executor = _.find($scope.framework.executors.concat($scope.framework.completed_executors),
-            function(executor) {
-              return $scope.executor_id === executor.id;
-            });
+        $scope.executor =
+          _.find($scope.framework.executors, matchExecutor) ||
+          _.find($scope.framework.completed_executors, matchExecutor);
 
         if (!$scope.executor) {
           $scope.alert_message = 'No executor found with ID: ' + $routeParams.executor_id;