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

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-fury.git


The following commit(s) were added to refs/heads/main by this push:
     new d28b14da chore(java): add comments for loop unrolling. (#1450)
d28b14da is described below

commit d28b14dabaa6eccedf53353a8de2ca6925ffd48e
Author: LiangliangSui <116876207+liangliang...@users.noreply.github.com>
AuthorDate: Sun Apr 7 01:31:46 2024 +0800

    chore(java): add comments for loop unrolling. (#1450)
    
    N/A
    
    ---------
    
    Signed-off-by: LiangliangSui <coolsui.cod...@gmail.com>
---
 .../src/main/java/org/apache/fury/memory/MemoryBuffer.java       | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java 
b/java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java
index 025ceb28..011b31a7 100644
--- a/java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java
+++ b/java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java
@@ -1239,6 +1239,9 @@ public final class MemoryBuffer {
   }
 
   private int readPositiveVarIntSlow() {
+    // Note:
+    //  Loop are not used here to improve performance,
+    //  we manually unroll the loop for better performance.
     int b = readByte();
     int result = b & 0x7F;
     if ((b & 0x80) != 0) {
@@ -1468,6 +1471,9 @@ public final class MemoryBuffer {
     // Mask first 6 bits,
     // bit 8 `set` indicates have next data bytes.
     int result = b & 0x3F;
+    // Note:
+    //  Loop are not used here to improve performance.
+    //  We manually unroll the loop for better performance.
     if ((b & 0x80) != 0) { // has 2nd byte
       b = UNSAFE.getByte(heapMemory, pos++);
       result |= (b & 0x3F) << 6;
@@ -1768,6 +1774,9 @@ public final class MemoryBuffer {
   private long readPositiveVarLongSlow() {
     long b = readByte();
     long result = b & 0x7F;
+    // Note:
+    //  Loop are not used here to improve performance.
+    //  We manually unroll the loop for better performance.
     if ((b & 0x80) != 0) {
       b = readByte();
       result |= (b & 0x7F) << 7;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org

Reply via email to