@@ -75,7 +75,7 @@ public double getDouble(int index) {
7575 public void getBytes (int index , int len , ByteBuffer dst ) {
7676 try {
7777 reference .position (index );
78- reference .limit (index + len );
78+ reference .limit (index + len );
7979 dst .put (reference );
8080 }
8181 finally {
@@ -114,7 +114,7 @@ public void putDouble(int index, double v) {
114114 public ByteBuffer toByteBuffer (int index , int length ) {
115115 try {
116116 reference .position (index );
117- reference .limit (index + length );
117+ reference .limit (index + length );
118118 return reference .slice ();
119119 }
120120 finally {
@@ -142,15 +142,19 @@ public void putByteBuffer(int index, ByteBuffer src, int len) {
142142 assert (len <= src .remaining ());
143143
144144 if (src .hasArray ()) {
145- byte [] srcArray = src .array ();
146- putBytes (index , srcArray , src .position (), len );
147-
148- } else {
149- for (int i = 0 ; i < len ; ++i ) {
150- putByte (index + i , src .get ());
145+ putBytes (index , src .array (), src .position (), len );
146+ src .position (src .position () + len );
147+ }
148+ else {
149+ int prevSrcLimit = src .limit ();
150+ try {
151+ src .limit (src .position () + len );
152+ reference .put (src );
153+ }
154+ finally {
155+ src .limit (prevSrcLimit );
151156 }
152157 }
153- src .position (src .position () + len );
154158 }
155159
156160 @ Override
0 commit comments