Skip to content

Commit 3e0ee3e

Browse files
committed
Reduce the number of charset lookups performed in BinaryValue under the hood
1 parent e385fc3 commit 3e0ee3e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/basho/riak/client/core/util/BinaryValue.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
*/
4242
public final class BinaryValue
4343
{
44+
/**
45+
* It is expected that UTF-8 charset is available.
46+
*/
47+
private static final Charset theUTF8 = Charset.forName("UTF-8");
48+
4449
private final byte[] data;
4550

4651
private BinaryValue(byte[] data)
@@ -87,7 +92,7 @@ public static BinaryValue create(String data)
8792
*/
8893
public static BinaryValue createFromUtf8(String data)
8994
{
90-
return create(data, Charset.forName("UTF-8"));
95+
return create(data, theUTF8);
9196
}
9297

9398
/**
@@ -197,7 +202,7 @@ public String toString()
197202
*/
198203
public String toStringUtf8()
199204
{
200-
return toString(Charset.forName("UTF-8"));
205+
return toString(theUTF8);
201206
}
202207

203208
/**

0 commit comments

Comments
 (0)