aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Arnavi4FrameDecoder.java
diff options
context:
space:
mode:
authorIvan Muratov <binakot@gmail.com>2017-07-14 09:32:52 +0300
committerIvan Muratov <binakot@gmail.com>2017-07-14 09:32:52 +0300
commita71dd10a966b491c64232180a2075450f0a258db (patch)
tree19a68cd6de1909a92974655947819d0fafbda575 /src/org/traccar/protocol/Arnavi4FrameDecoder.java
parent50d45d27beb423c1689f83401d0adb88b7fafb65 (diff)
downloadtrackermap-server-a71dd10a966b491c64232180a2075450f0a258db.tar.gz
trackermap-server-a71dd10a966b491c64232180a2075450f0a258db.tar.bz2
trackermap-server-a71dd10a966b491c64232180a2075450f0a258db.zip
Switch from the unnecessary creating the byte array to direct working with origin buffer.
Remove tag value parsing inside case block.
Diffstat (limited to 'src/org/traccar/protocol/Arnavi4FrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/Arnavi4FrameDecoder.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/Arnavi4FrameDecoder.java b/src/org/traccar/protocol/Arnavi4FrameDecoder.java
index 2587420c9..a50ece641 100644
--- a/src/org/traccar/protocol/Arnavi4FrameDecoder.java
+++ b/src/org/traccar/protocol/Arnavi4FrameDecoder.java
@@ -44,19 +44,16 @@ public class Arnavi4FrameDecoder extends FrameDecoder {
return null;
}
- byte[] bytes = new byte[buf.readableBytes()];
- buf.getBytes(0, bytes);
-
- if (bytes[0] == HEADER_START_SIGN
- && bytes.length == HEADER_LENGTH
- && (bytes[1] == HEADER_VERSION_1 || bytes[1] == HEADER_VERSION_2)) {
+ if (buf.getByte(0) == HEADER_START_SIGN
+ && buf.readableBytes() == HEADER_LENGTH
+ && (buf.getByte(1) == HEADER_VERSION_1 || buf.getByte(1) == HEADER_VERSION_2)) {
return buf.readBytes(HEADER_LENGTH);
}
- int parcelNumber = bytes[1] & 0xFF;
- if (bytes[0] == PACKAGE_START_SIGN && bytes[bytes.length - 1] == PACKAGE_END_SIGN
+ int parcelNumber = buf.getByte(1) & 0xFF;
+ if (buf.getByte(0) == PACKAGE_START_SIGN && buf.getByte(buf.readableBytes() - 1) == PACKAGE_END_SIGN
&& parcelNumber >= PACKAGE_MIN_PARCEL_NUMBER && parcelNumber <= PACKAGE_MAX_PARCEL_NUMBER) {
- return buf.readBytes(bytes.length);
+ return buf;
}
return null;