jengebr commented on code in PR #2593:
URL: https://github.com/apache/logging-log4j2/pull/2593#discussion_r1613587486


##########
log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java:
##########
@@ -268,21 +265,11 @@ public static void putIfNull(final String key, final 
String value) {
      *
      * <p>If the current thread does not have a context map it is
      * created as a side effect.</p>
-     * @param m The map.
+     * @param map The map.
      * @since 2.7
      */
-    public static void putAll(final Map<String, String> m) {
-        if (contextMap instanceof ThreadContextMap2) {
-            ((ThreadContextMap2) contextMap).putAll(m);
-        } else if (contextMap instanceof DefaultThreadContextMap) {
-            ((DefaultThreadContextMap) contextMap).putAll(m);
-        } else if (contextMap instanceof StringArrayThreadContextMap) {
-            ((StringArrayThreadContextMap) contextMap).putAll(m);
-        } else {
-            for (final Map.Entry<String, String> entry : m.entrySet()) {
-                contextMap.put(entry.getKey(), entry.getValue());
-            }
-        }
+    public static void putAll(final Map<String, String> map) {
+        contextMap.putAll(map);

Review Comment:
   Please maintain separate if/else branches for the most common instance 
types, as in the previous version.  This avoids virtual method lookups for 
those types.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to