This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0506369355552c2736e0305efd9d3395485d4e35
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Apr 7 18:26:17 2021 +0200

    CAMEL-16462: camel-core - Optimize Splitter EIP to reduce object 
allocations.
---
 .../src/main/java/org/apache/camel/processor/Splitter.java          | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
index 1d2b444..64fd105 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
@@ -161,7 +161,6 @@ public class Splitter extends MulticastProcessor implements 
AsyncProcessor, Trac
     @Override
     protected Iterable<ProcessorExchangePair> 
createProcessorExchangePairs(Exchange exchange)
             throws Exception {
-        // iter is only currently used by Recipient List EIP so its null
 
         Object value = expression.evaluate(exchange, Object.class);
         if (exchange.getException() != null) {
@@ -211,7 +210,7 @@ public class Splitter extends MulticastProcessor implements 
AsyncProcessor, Trac
             this.original = exchange;
             this.value = value;
 
-            if (delimiter != null && 
IGNORE_DELIMITER_MARKER.equalsIgnoreCase(delimiter)) {
+            if (IGNORE_DELIMITER_MARKER.equalsIgnoreCase(delimiter)) {
                 this.iterator = ObjectHelper.createIterator(value, null);
             } else {
                 this.iterator = ObjectHelper.createIterator(value, delimiter);
@@ -224,6 +223,7 @@ public class Splitter extends MulticastProcessor implements 
AsyncProcessor, Trac
         @Override
         public Iterator<ProcessorExchangePair> iterator() {
             return new Iterator<ProcessorExchangePair>() {
+                private final Processor processor = 
getProcessors().iterator().next();
                 private int index;
                 private boolean closed;
 
@@ -270,7 +270,7 @@ public class Splitter extends MulticastProcessor implements 
AsyncProcessor, Trac
                             Message in = newExchange.getIn();
                             in.setBody(part);
                         }
-                        return createProcessorExchangePair(index++, 
getProcessors().iterator().next(), newExchange, route);
+                        return createProcessorExchangePair(index++, processor, 
newExchange, route);
                     } else {
                         return null;
                     }

Reply via email to