qos-ch / slf4j

Simple Logging Facade for Java
http://www.slf4j.org
MIT License
2.34k stars 990 forks source link

Optimization suggestion for org.slf4j.helpers.MessageFormatter.arrayFormat(String, Object[], Throwable) #435

Open dukeware opened 1 month ago

dukeware commented 1 month ago

In order to reduce unnecessary expenses:

deeplyAppendParameter(sbuf, argArray[L], new HashMap<>());

should be:

deeplyAppendParameter(sbuf, argArray[L], null);

Correspondingly, in org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(StringBuilder, Object, Map<Object[], Object>)

objectArrayAppend(sbuf, (Object[]) o, seenMap);

change to:

objectArrayAppend(sbuf, (Object[]) o, seenMap != null ? seenMap : new HashMap<>());