mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
ThreadLocalStringBuilder is slower here
by about 30%, as measured by JMH avoiding garbage is more important when the string is more than 5 characters long
This commit is contained in:
parent
f438b76b31
commit
8109532adf
1 changed files with 1 additions and 4 deletions
|
@ -31,12 +31,9 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.util.Copyable;
|
||||
import mage.util.ThreadLocalStringBuilder;
|
||||
|
||||
public class ObjectColor implements Serializable, Copyable<ObjectColor>, Comparable<ObjectColor> {
|
||||
|
||||
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(10);
|
||||
|
||||
public static final ObjectColor WHITE = new ObjectColor("W");
|
||||
public static final ObjectColor BLUE = new ObjectColor("U");
|
||||
public static final ObjectColor BLACK = new ObjectColor("B");
|
||||
|
@ -231,7 +228,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = threadLocalBuilder.get();
|
||||
StringBuilder sb = new StringBuilder(5);
|
||||
if (white) {
|
||||
sb.append("W");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue