Instead of copying arrays around, use offset-based parsers from
IetfInetUtil.
Change-Id: I2d5f8f799ae61e1d6d247827b9d0d1cee6e8b9ef
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
(cherry picked from commit
e7ffadf95911352e64f93d2357dffa1a7ff52741)
list.add(EMPTY_PREFIX);
continue;
}
- final int byteCount = (bitLength % Byte.SIZE != 0) ? (bitLength / Byte.SIZE) + 1 : bitLength / Byte.SIZE;
- list.add(prefixForBytes(ByteArray.subByte(bytes, byteOffset, byteCount), bitLength));
- byteOffset += byteCount;
+
+ list.add(IetfInetUtil.INSTANCE.ipv4PrefixForShort(bytes, byteOffset, bitLength));
+ byteOffset += bitLength / Byte.SIZE;
+ if (bitLength % Byte.SIZE != 0) {
+ byteOffset++;
+ }
}
return list;
list.add(EMPTY_PREFIX);
continue;
}
- final int byteCount = (bitLength % Byte.SIZE != 0) ? (bitLength / Byte.SIZE) + 1 : bitLength / Byte.SIZE;
- list.add(prefixForBytes(ByteArray.subByte(bytes, byteOffset, byteCount), bitLength));
- byteOffset += byteCount;
-
+ list.add(IetfInetUtil.INSTANCE.ipv6PrefixForShort(bytes, byteOffset, bitLength));
+ byteOffset += bitLength / Byte.SIZE;
+ if (bitLength % Byte.SIZE != 0) {
+ byteOffset++;
+ }
}
return list;
}