karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [06/11] karaf git commit: Remove some calls to getFeatures() so not we only call it once for a given method
Date Mon, 15 May 2017 13:12:06 GMT
Remove some calls to getFeatures() so not we only call it once for a given method

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6abe1379
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6abe1379
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6abe1379

Branch: refs/heads/master
Commit: 6abe1379bc7f89174c07d6e585a37089e5b92288
Parents: 66d85a7
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Mon May 15 14:32:52 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Mon May 15 14:32:52 2017 +0200

----------------------------------------------------------------------
 .../internal/service/FeaturesServiceImpl.java         | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/6abe1379/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index ce318ac..b22ae3c 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -627,7 +627,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
 
     @Override
     public Feature getFeature(String name) throws Exception {
-        Feature[] features = this.getFeatures(name);
+        Feature[] features = getFeatures(name);
         if (features.length < 1) {
             return null;
         } else {
@@ -637,7 +637,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
 
     @Override
     public Feature getFeature(String name, String version) throws Exception {
-        Feature[] features = this.getFeatures(name, version);
+        Feature[] features = getFeatures(name, version);
         if (features.length < 1) {
             return null;
         } else {
@@ -657,10 +657,11 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
     public Feature[] getFeatures(String name, String version) throws Exception {
         List<Feature> features = new ArrayList<>();
         Pattern pattern = Pattern.compile(name);
-        for (String featureName : getFeatures().keySet()) {
+        Map<String, Map<String, Feature>> allFeatures = getFeatures();
+        for (String featureName : allFeatures.keySet()) {
             Matcher matcher = pattern.matcher(featureName);
             if (matcher.matches()) {
-                Map<String, Feature> versions = getFeatures().get(featureName);
+                Map<String, Feature> versions = allFeatures.get(featureName);
                 Feature matchingFeature = getFeatureMatching(versions, version);
                 if (matchingFeature != null) {
                     features.add(matchingFeature);
@@ -923,6 +924,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             region = ROOT_REGION;
         }
         Set<String> fl = required.computeIfAbsent(region, k -> new HashSet<>());
+        Map<String, Map<String, Feature>> allFeatures = getFeatures();
         List<String> featuresToAdd = new ArrayList<>();
         List<String> featuresToRemove = new ArrayList<>();
         for (String feature : features) {
@@ -931,10 +933,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             String version = feature.substring(feature.indexOf(VERSION_SEPARATOR) + 1);
             Pattern pattern = Pattern.compile(name);
             boolean matched = false;
-            for (String fKey : getFeatures().keySet()) {
+            for (String fKey : allFeatures.keySet()) {
                 Matcher matcher = pattern.matcher(fKey);
                 if (matcher.matches()) {
-                    Feature f = getFeatureMatching(getFeatures().get(fKey), version);
+                    Feature f = getFeatureMatching(allFeatures.get(fKey), version);
                     if (f != null) {
                         String req = getFeatureRequirement(f);
                         featuresToAdd.add(req);


Mime
View raw message