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 c4d891498f7 CAMEL-19828: avoid iterating twice over the converters' map (#11933) c4d891498f7 is described below commit c4d891498f7c14d1541de751fd8e682a66d6f1f8 Author: Otavio Rodolfo Piske <orpi...@users.noreply.github.com> AuthorDate: Wed Nov 8 08:19:31 2023 +0100 CAMEL-19828: avoid iterating twice over the converters' map (#11933) --- .../apache/camel/impl/converter/TypeResolverHelper.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/converter/TypeResolverHelper.java b/core/camel-base/src/main/java/org/apache/camel/impl/converter/TypeResolverHelper.java index 0bf70f7dcfa..fad4dab1926 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/converter/TypeResolverHelper.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/converter/TypeResolverHelper.java @@ -115,16 +115,14 @@ final class TypeResolverHelper { matching both the "from type" and the "to type" which are NOT Object (we usually try this later). */ for (var entry : converters.entrySet()) { - if (entry.getKey().isAssignableMatch(typeConvertible)) { + final TypeConvertible<?, ?> key = entry.getKey(); + if (key.isAssignableMatch(typeConvertible)) { return entry.getValue(); + } else { + if (typeConvertible.isAssignableMatch(key)) { + return entry.getValue(); + } } - - } - for (var entry : converters.entrySet()) { - if (typeConvertible.isAssignableMatch(entry.getKey())) { - return entry.getValue(); - } - } return null;