Avoid creating new KryoNamespace instance.
- Avoid creating new KryoNamespace instance when there's only 1 namespace specified. Change-Id: I7acd1af21623660d6de4f1090b0731a15762cd14
Showing
1 changed file
with
12 additions
and
1 deletions
... | @@ -50,7 +50,18 @@ public interface Serializer { | ... | @@ -50,7 +50,18 @@ public interface Serializer { |
50 | * @return Serializer instance | 50 | * @return Serializer instance |
51 | */ | 51 | */ |
52 | static Serializer using(KryoNamespace kryo) { | 52 | static Serializer using(KryoNamespace kryo) { |
53 | - return using(Arrays.asList(kryo)); | 53 | + return new Serializer() { |
54 | + | ||
55 | + @Override | ||
56 | + public <T> byte[] encode(T object) { | ||
57 | + return kryo.serialize(object); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public <T> T decode(byte[] bytes) { | ||
62 | + return kryo.deserialize(bytes); | ||
63 | + } | ||
64 | + }; | ||
54 | } | 65 | } |
55 | 66 | ||
56 | /** | 67 | /** | ... | ... |
-
Please register or login to post a comment