[camel] branch master updated: CAMEL-14354: Optimize core

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-14354: Optimize core

davsclaus-2
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


The following commit(s) were added to refs/heads/master by this push:
     new 6aa17a9   CAMEL-14354: Optimize core
6aa17a9 is described below

commit 6aa17a949b275d11f8f60259f7a22320d13002b2
Author: Claus Ibsen <[hidden email]>
AuthorDate: Wed Jan 22 06:03:13 2020 +0100

     CAMEL-14354: Optimize core
---
 .../management/DefaultInstrumentationProcessor.java  | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/core/camel-management/src/main/java/org/apache/camel/management/DefaultInstrumentationProcessor.java b/core/camel-management/src/main/java/org/apache/camel/management/DefaultInstrumentationProcessor.java
index 02960af..52f4042 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/DefaultInstrumentationProcessor.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/DefaultInstrumentationProcessor.java
@@ -68,24 +68,22 @@ public class DefaultInstrumentationProcessor extends DelegateAsyncProcessor
     public boolean process(final Exchange exchange, final AsyncCallback callback) {
         final StopWatch watch = before(exchange);
 
-        return processor.process(exchange, new AsyncCallback() {
-            public void done(boolean doneSync) {
+        // optimize to only create a new callback if needed
+        AsyncCallback ac = callback;
+        boolean newCallback = watch != null;
+        if (newCallback) {
+            ac = doneSync -> {
                 try {
                     // record end time
-                    if (watch != null) {
-                        after(exchange, watch);
-                    }
+                    after(exchange, watch);
                 } finally {
                     // and let the original callback know we are done as well
                     callback.done(doneSync);
                 }
-            }
+            };
+        }
 
-            @Override
-            public String toString() {
-                return DefaultInstrumentationProcessor.this.toString();
-            }
-        });
+        return processor.process(exchange, ac);
     }
 
     protected void beginTime(Exchange exchange) {