Skip to content

Commit

Permalink
Merge pull request #688 from basho/speedup-binaryval-utf8
Browse files Browse the repository at this point in the history
Reduce the number of charset lookups performed in BinaryValue under t…
  • Loading branch information
alexmoore authored Nov 16, 2016
2 parents d9a254d + 3e0ee3e commit 6d7a9d2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
*/
public final class BinaryValue
{
/**
* It is expected that UTF-8 charset is available.
*/
private static final Charset theUTF8 = Charset.forName("UTF-8");

private final byte[] data;

private BinaryValue(byte[] data)
Expand Down Expand Up @@ -87,7 +92,7 @@ public static BinaryValue create(String data)
*/
public static BinaryValue createFromUtf8(String data)
{
return create(data, Charset.forName("UTF-8"));
return create(data, theUTF8);
}

/**
Expand Down Expand Up @@ -197,7 +202,7 @@ public String toString()
*/
public String toStringUtf8()
{
return toString(Charset.forName("UTF-8"));
return toString(theUTF8);
}

/**
Expand Down

0 comments on commit 6d7a9d2

Please sign in to comment.