1+ // Protocol Buffers - Google's data interchange format
2+ // Copyright 2008 Google Inc. All rights reserved.
3+ //
4+ // Use of this source code is governed by a BSD-style
5+ // license that can be found in the LICENSE file or at
6+ // https://developers.google.com/open-source/licenses/bsd
7+
8+ // I'm not sure if the LICENSE copyright header is necessary as only two methods in this class are taken from Google's source code
9+ // But just to be sure I included it
10+
111package it .auties .protobuf .stream ;
212
313import it .auties .protobuf .exception .ProtobufDeserializationException ;
@@ -183,6 +193,8 @@ public int readInt32() {
183193 return readInt32Unchecked ();
184194 }
185195
196+ // Source: https://github.com/protocolbuffers/protobuf/blob/main/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
197+ // Fastest implementation I could find
186198 private int readInt32Unchecked () {
187199 fspath :
188200 {
@@ -219,7 +231,9 @@ private int readInt32Unchecked() {
219231
220232 return (int ) readVarInt64Slow ();
221233 }
222-
234+
235+ // Source: https://github.com/protocolbuffers/protobuf/blob/main/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
236+ // Fastest implementation I could find
223237 public long readInt64 () {
224238 if (wireType != ProtobufWireType .WIRE_TYPE_VAR_INT ) {
225239 throw ProtobufDeserializationException .invalidWireType (wireType );
@@ -306,7 +320,10 @@ public int readFixed32() {
306320
307321 byte [] buffer = this .buffer ;
308322 this .pos = tempPos + 4 ;
309- return buffer [tempPos ] & 255 | (buffer [tempPos + 1 ] & 255 ) << 8 | (buffer [tempPos + 2 ] & 255 ) << 16 | (buffer [tempPos + 3 ] & 255 ) << 24 ;
323+ return buffer [tempPos ] & 255
324+ | (buffer [tempPos + 1 ] & 255 ) << 8
325+ | (buffer [tempPos + 2 ] & 255 ) << 16
326+ | (buffer [tempPos + 3 ] & 255 ) << 24 ;
310327 }
311328
312329 public long readFixed64 () {
@@ -321,7 +338,14 @@ public long readFixed64() {
321338
322339 byte [] buffer = this .buffer ;
323340 this .pos = tempPos + 8 ;
324- return (long ) buffer [tempPos ] & 255L | ((long ) buffer [tempPos + 1 ] & 255L ) << 8 | ((long ) buffer [tempPos + 2 ] & 255L ) << 16 | ((long ) buffer [tempPos + 3 ] & 255L ) << 24 | ((long ) buffer [tempPos + 4 ] & 255L ) << 32 | ((long ) buffer [tempPos + 5 ] & 255L ) << 40 | ((long ) buffer [tempPos + 6 ] & 255L ) << 48 | ((long ) buffer [tempPos + 7 ] & 255L ) << 56 ;
341+ return (long ) buffer [tempPos ] & 255L
342+ | ((long ) buffer [tempPos + 1 ] & 255L ) << 8
343+ | ((long ) buffer [tempPos + 2 ] & 255L ) << 16
344+ | ((long ) buffer [tempPos + 3 ] & 255L ) << 24
345+ | ((long ) buffer [tempPos + 4 ] & 255L ) << 32
346+ | ((long ) buffer [tempPos + 5 ] & 255L ) << 40
347+ | ((long ) buffer [tempPos + 6 ] & 255L ) << 48
348+ | ((long ) buffer [tempPos + 7 ] & 255L ) << 56 ;
325349 }
326350
327351 public byte readByte () {
0 commit comments