From 0a18b2dca695c152323a2888e5c2e3a4b63a4ae6 Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Sun, 11 May 2014 13:53:46 -0400 Subject: [PATCH] use bulk get() --- src/capnp/Text.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/capnp/Text.java b/src/capnp/Text.java index c75e0a8..dcab278 100644 --- a/src/capnp/Text.java +++ b/src/capnp/Text.java @@ -18,10 +18,8 @@ public class Text { public String toString() { byte[] bytes = new byte[this.size]; - // why is there no absolute get() method on ByteArray? - for (int ii = 0; ii < this.size; ++ii) { - bytes[ii] = this.buffer.get(this.offset + ii); - } + this.buffer.position(this.offset); + this.buffer.get(bytes, 0, this.size); try { return new String(bytes, "UTF-8");