karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/5] karaf git commit: Optimize string operations
Date Fri, 15 Sep 2017 09:41:47 GMT
Repository: karaf
Updated Branches:
  refs/heads/master e4ccd2c39 -> cf651678c


Optimize string operations


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

Branch: refs/heads/master
Commit: 02350ad10ffb5972dd416f722eec33509defddb5
Parents: 4dbc729
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Fri Sep 15 08:01:25 2017 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Fri Sep 15 08:01:25 2017 +0200

----------------------------------------------------------------------
 .../org/apache/karaf/features/internal/model/Feature.java   | 8 ++++----
 .../apache/karaf/features/internal/region/Subsystem.java    | 2 +-
 .../features/internal/service/FeaturesServiceImpl.java      | 9 +++++----
 3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
b/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
index 752d2a8..9e838e6 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
@@ -127,10 +127,10 @@ public class Feature extends Content implements org.apache.karaf.features.Featur
     }
 
     public static org.apache.karaf.features.Feature valueOf(String str) {
-        if (str.contains(VERSION_SEPARATOR)) {
-            String strName = str.substring(0, str.indexOf(VERSION_SEPARATOR));
-            String strVersion = str.substring(str.indexOf(VERSION_SEPARATOR)
-                    + VERSION_SEPARATOR.length(), str.length());
+        int idx = str.indexOf(VERSION_SEPARATOR);
+        if (idx >= 0) {
+            String strName = str.substring(0, idx);
+            String strVersion = str.substring(idx + VERSION_SEPARATOR.length(), str.length());
             return new Feature(strName, strVersion);
         } else {
             return new Feature(str);

http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
index 88b4412..33b9dae 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
@@ -227,7 +227,7 @@ public class Subsystem extends ResourceImpl {
     }
 
     public void require(String requirement) throws BundleException {
-        int idx = requirement.indexOf(":");
+        int idx = requirement.indexOf(':');
         String type, req;
         if (idx >= 0) {
             type = requirement.substring(0, idx);

http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/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 c1e7b0c..932fd41 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
@@ -82,6 +82,8 @@ import org.slf4j.LoggerFactory;
 
 import static java.util.Collections.emptyMap;
 import static java.util.stream.Collectors.toSet;
+import static org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION;
+import static org.apache.karaf.features.internal.model.Feature.VERSION_SEPARATOR;
 import static org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap;
 import static org.apache.karaf.features.internal.util.MapUtils.*;
 
@@ -92,7 +94,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
 
     private static final String RESOLVE_FILE = "resolve";
     private static final Logger LOGGER = LoggerFactory.getLogger(FeaturesServiceImpl.class);
-    private static final String VERSION_SEPARATOR = "/";
 
     /**
      * Used to load and save the {@link State} of this service.
@@ -893,10 +894,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
     }
 
     private String normalize(String feature) {
-        if (!feature.contains(VERSION_SEPARATOR)) {
-            feature += "/0.0.0";
-        }
         int idx = feature.indexOf(VERSION_SEPARATOR);
+        if (idx < 0) {
+            return feature + VERSION_SEPARATOR + DEFAULT_VERSION;
+        }
         String name = feature.substring(0, idx);
         String version = feature.substring(idx + 1);
         return name + VERSION_SEPARATOR + VersionCleaner.clean(version);


Mime
View raw message