This is an automated email from the ASF dual-hosted git repository.

dmollitor pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/main by this push:
     new d6f755f58 AVRO-4052: Inline BufferedBinaryEncoder writeZero method 
(#3145)
d6f755f58 is described below

commit d6f755f58afdceaeb66eb9bd915d94ebaa111e81
Author: belugabehr <[email protected]>
AuthorDate: Sat Sep 14 22:50:51 2024 -0400

    AVRO-4052: Inline BufferedBinaryEncoder writeZero method (#3145)
---
 .../main/java/org/apache/avro/io/BufferedBinaryEncoder.java   | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
index 376289ec8..35b515ad1 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
@@ -41,7 +41,7 @@ import org.apache.avro.AvroRuntimeException;
  * <p/>
  * To change the buffer size, configure the factory instance used to create
  * instances with {@link EncoderFactory#configureBufferSize(int)}
- * 
+ *
  * @see Encoder
  * @see EncoderFactory
  * @see BlockingBinaryEncoder
@@ -105,7 +105,7 @@ public class BufferedBinaryEncoder extends BinaryEncoder {
    * current position and the end. This will not expand the buffer larger than 
its
    * current size, for writes larger than or near to the size of the buffer, we
    * flush the buffer and write directly to the output, bypassing the buffer.
-   * 
+   *
    * @param num
    * @throws IOException
    */
@@ -175,14 +175,11 @@ public class BufferedBinaryEncoder extends BinaryEncoder {
 
   @Override
   protected void writeZero() throws IOException {
-    writeByte(0);
-  }
-
-  private void writeByte(int b) throws IOException {
+    // inlined, shorter version of writeZero
     if (pos == buf.length) {
       flushBuffer();
     }
-    buf[pos++] = (byte) (b & 0xFF);
+    buf[pos++] = (byte) 0;
   }
 
   @Override

Reply via email to