You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/06/24 18:06:58 UTC

[GitHub] [logging-log4j2] vy commented on a change in pull request #532: Replace loop with bulk method.

vy commented on a change in pull request #532:
URL: https://github.com/apache/logging-log4j2/pull/532#discussion_r658172667



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java
##########
@@ -53,9 +54,7 @@ private TypeUtil() {
     public static List<Field> getAllDeclaredFields(Class<?> cls) {
         final List<Field> fields = new ArrayList<>();
         while (cls != null) {
-            for (final Field field : cls.getDeclaredFields()) {
-                fields.add(field);
-            }
+            fields.addAll(Arrays.asList(cls.getDeclaredFields()));

Review comment:
       I have the impression that we are adding an extra GC load to a commonly used part of the code base. I'd prefer the earlier approach. Would you mind reverting this, please?




-- 
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:
users@infra.apache.org