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

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


The following commit(s) were added to refs/heads/main by this push:
     new 296f5228854 CAMEL-20070: avoid unnecessary costly comparisons
296f5228854 is described below

commit 296f5228854dff5180ec9c19031f9298a9c23d45
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Nov 2 10:16:42 2023 +0200

    CAMEL-20070: avoid unnecessary costly comparisons
    
     This avoids unnecessary costly comparisons when we can eagerly determine 
that the types won't match. We can avoid these comparisons when both the from 
types are the same, but their to type are not, because we only use the from 
types to compute the match.
---
 .../src/main/java/org/apache/camel/converter/TypeConvertible.java    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java 
b/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java
index 7b5969c21a3..833fd5a3dd7 100644
--- 
a/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java
+++ 
b/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java
@@ -98,6 +98,11 @@ public final class TypeConvertible<F, T> {
             return true;
         }
 
+        // They are the same, but the thisTo and thatTo don't match.
+        if (thisFrom == thatFrom) {
+            return false;
+        }
+
         /* Try interfaces:
          * Try to resolve a TypeConverter by looking at the interfaces 
implemented by a given "from" type. It looks at the
          * type hierarchy of the target "from type" trying to match a suitable 
converter (i.e.: Integer -> Number). It will

Reply via email to