From 024d9cf87a058cf1e5923943af427cb8487abedb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 9 Jun 2018 10:01:09 +1200 Subject: Improve buffer util --- src/org/traccar/helper/BufferUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/helper/BufferUtil.java b/src/org/traccar/helper/BufferUtil.java index c046fcaf5..81a081182 100644 --- a/src/org/traccar/helper/BufferUtil.java +++ b/src/org/traccar/helper/BufferUtil.java @@ -33,10 +33,10 @@ public final class BufferUtil { } public static int indexOf(String needle, ByteBuf haystack, int startIndex, int endIndex) { - int index = ByteBufUtil.indexOf( - Unpooled.wrappedBuffer(needle.getBytes(StandardCharsets.US_ASCII)), - Unpooled.wrappedBuffer(haystack.array(), startIndex, endIndex - startIndex)); - return (index != -1) ? (startIndex + index) : -1; + haystack = Unpooled.wrappedBuffer(haystack); + haystack.readerIndex(startIndex); + haystack.writerIndex(endIndex); + return indexOf(needle, haystack); } } -- cgit v1.2.3