aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MegastekFrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 11:53:11 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 11:53:11 +1200
commitc40928cd674144fa5ed3dc7306c33b16823b2fad (patch)
tree1180e335ca1ad10c4cb40033c7acf2b62dfbc8d1 /src/org/traccar/protocol/MegastekFrameDecoder.java
parent44cdc3449fccd22b21fec1c9a0febea807cc2489 (diff)
downloadtrackermap-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.tar.gz
trackermap-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.tar.bz2
trackermap-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.zip
Use slices instead of new buffers
Diffstat (limited to 'src/org/traccar/protocol/MegastekFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/MegastekFrameDecoder.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MegastekFrameDecoder.java b/src/org/traccar/protocol/MegastekFrameDecoder.java
index 0bdd06a79..347fa24b1 100644
--- a/src/org/traccar/protocol/MegastekFrameDecoder.java
+++ b/src/org/traccar/protocol/MegastekFrameDecoder.java
@@ -36,7 +36,7 @@ public class MegastekFrameDecoder extends BaseFrameDecoder {
if (Character.isDigit(buf.getByte(buf.readerIndex()))) {
int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII));
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else {
while (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n') {
@@ -47,7 +47,7 @@ public class MegastekFrameDecoder extends BaseFrameDecoder {
delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '!');
}
if (delimiter != -1) {
- ByteBuf result = buf.readBytes(delimiter - buf.readerIndex());
+ ByteBuf result = buf.readRetainedSlice(delimiter - buf.readerIndex());
buf.skipBytes(1);
return result;
}