[PATCH] Code simplification + moved code out of inner loop

Wald Commits scm-commit at wald.intevation.org
Fri Oct 4 18:33:53 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1380904424 -7200
# Node ID 965dbf2d4c44248220c968a01f21bf8b6e2bbf41
# Parent  737dd43e32d6cc837410dfe4153ebacda52fd90b
Code simplification + moved code out of inner loop.

diff -r 737dd43e32d6 -r 965dbf2d4c44 artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java	Fri Oct 04 18:21:25 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java	Fri Oct 04 18:33:44 2013 +0200
@@ -1306,11 +1306,8 @@
         FacetFilter facetFilter =
             (FacetFilter)RiverContextFactory.getGlobalContext()
                 .get(RiverContext.FACETFILTER_KEY);
-        if (facetFilter == null) {
-            return false;
-        }
 
-        return true;
+        return facetFilter != null;
     }
 
     /** If a global facet filter and a bounded out are defined
@@ -1342,14 +1339,21 @@
      * @param fs List of facets
      */
     protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
-        List<Output> generated = new ArrayList<Output>();
-        log.debug("generateOutputs for Artifact " + getName() + " "
-                + identifier());
-
         boolean debug = log.isDebugEnabled();
 
+        List<Output> generated = new ArrayList<Output>();
+
+        if (debug) {
+            log.debug("generateOutputs for Artifact " + getName() + " "
+                + identifier());
+        }
+
+        boolean useFacetFilter = usesOutputFacetFilter();
+
         for (Output out: list) {
-            log.debug("check facets for output: " + out.getName());
+            if (debug) {
+                log.debug("check facets for output: " + out.getName());
+            }
             String outName = out.getName();
             Output o = new DefaultOutput(
                 outName,
@@ -1372,7 +1376,7 @@
                 /* Match the facets to the output configuration.
                  * This is only done when we are not using the Output
                  * we are bound to to determine the compatible facets. */
-                if (outTypes.contains(type) || usesOutputFacetFilter()) {
+                if (useFacetFilter || outTypes.contains(type)) {
                     if (debug) {
                         log.debug("Add facet " + f);
                     }


More information about the Dive4elements-commits mailing list