File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/main/java/com/maxmind/db Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1515 * This class CANNOT be shared between threads
1616 */
1717final class Decoder {
18+ private static final Charset UTF_8 = Charset .forName ("UTF-8" );
19+
1820 // XXX - This is only for unit testings. We should possibly make a
1921 // constructor to set this
2022 boolean POINTER_TEST_HACK = false ;
@@ -183,9 +185,11 @@ private Result decodePointer(int ctrlByte, int offset) {
183185 }
184186
185187 private String decodeString (int size ) {
186- ByteBuffer buffer = this .buffer .slice ();
187- buffer .limit (size );
188- return Charset .forName ("UTF-8" ).decode (buffer ).toString ();
188+ int oldLimit = buffer .limit ();
189+ buffer .limit (buffer .position () + size );
190+ String s = UTF_8 .decode (buffer ).toString ();
191+ buffer .limit (oldLimit );
192+ return s ;
189193 }
190194
191195 private IntNode decodeUint16 (int size ) {
You can’t perform that action at this time.
0 commit comments