carterkozak commented on a change in pull request #335: Import of LogstashLayout as JsonTemplateLayout URL: https://github.com/apache/logging-log4j2/pull/335#discussion_r405621721
########## File path: log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java ########## @@ -55,14 +55,23 @@ public static String dquote(final String str) { } /** - * Checks if a String is blank. A blank string is one that is {@code null}, empty, or when trimmed using - * {@link String#trim()} is empty. + * Checks if a String is blank. A blank string is one that is either + * {@code null}, empty, or all characters are {@link Character#isWhitespace(char)}. * * @param s the String to check, may be {@code null} - * @return {@code true} if the String is {@code null}, empty, or trims to empty. + * @return {@code true} if the String is {@code null}, empty, or or all characters are {@link Character#isWhitespace(char)} */ public static boolean isBlank(final String s) { - return s == null || s.trim().isEmpty(); + if (s == null || s.isEmpty()) { + return true; + } + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (!Character.isWhitespace(c)) { + return false; + } + } Review comment: Trim allocates new strings, I like this optimization assuming the behavior is the same. It might be nice to separate this optimization into another change that's not related to the new json layout. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services