Skip to content

Commit

Permalink
Correction on StringBuilder default init size
Browse files Browse the repository at this point in the history
Motivation:
The default StringBuilder size is too small (data.length + 4) while it will be 2*data.length (byte to Hex) + 5 "-" char (since 5 peaces appended).

Modification:
Changing initial size to the correct one

Result:
Allocation of the correct final size from the beginning for this StringBuilder.
  • Loading branch information
fredericBregier authored and Norman Maurer committed May 30, 2014
1 parent ea0eb4f commit e1abfbb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public String asLongText() {
}

private String newLongValue() {
StringBuilder buf = new StringBuilder(data.length + 4);
StringBuilder buf = new StringBuilder(2 * data.length + 5);
int i = 0;
i = appendHexDumpField(buf, i, MACHINE_ID_LEN);
i = appendHexDumpField(buf, i, PROCESS_ID_LEN);
Expand Down

0 comments on commit e1abfbb

Please sign in to comment.