Hi Benedikt,

brit...@apache.org wrote:

> Repository: commons-lang
> Updated Branches:
>   refs/heads/master 8548b12d8 -> 60b32953a
> 
> 
> Allocate array of the correct size
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/commons-lang/commit/60b32953 Tree:
> http://git-wip-us.apache.org/repos/asf/commons-lang/tree/60b32953 Diff:
> http://git-wip-us.apache.org/repos/asf/commons-lang/diff/60b32953
> 
> Branch: refs/heads/master
> Commit: 60b32953a968e5623f82a6b27d6c679bc17c48e5
> Parents: 8548b12
> Author: Benedikt Ritter <brit...@apache.org>
> Authored: Mon May 4 21:26:07 2015 +0200
> Committer: Benedikt Ritter
> <brit...@apache.org> Committed: Mon May 4
> 21:26:07 2015 +0200
> 
> ----------------------------------------------------------------------
>  .../apache/commons/lang3/builder/ReflectionToStringBuilder.java    | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/60b32953/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
> ----------------------------------------------------------------------
> diff --git
> 
a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
> 
b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
> index 5904469..7a78170 100644 ---
> 
a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
> +++
> 
b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
> @@ -333,7 +333,7 @@ public class ReflectionToStringBuilder extends
> ToStringBuilder {
>                  list.add(e.toString());
>              }
>          }
> -        return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
> +        return list.toArray(new String[list.size()]);
>      }

What's the benefit of this? Where's the difference by letting List.toArray() 
allocate the appropriate array compared to do it on your own? 
ArrayUtils.EMPTY_STRING is a constant after all, so there's no additional 
allocation.

- Jörg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to