You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2024/10/15 14:13:17 UTC

(lucene) branch branch_10x updated: Optimize convert byte2int. (#13889)

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

jpountz pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 5727b8ce591 Optimize convert byte2int. (#13889)
5727b8ce591 is described below

commit 5727b8ce591cc5d63e080eb92476da346f2507a3
Author: zhouhui <vs...@163.com>
AuthorDate: Tue Oct 15 22:12:48 2024 +0800

    Optimize convert byte2int. (#13889)
---
 lucene/core/src/java/org/apache/lucene/util/fst/Util.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
index a6df78eaab5..c0f4bfeb572 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
@@ -775,10 +775,11 @@ public final class Util {
 
   /** Just takes unsigned byte values from the BytesRef and converts into an IntsRef. */
   public static IntsRef toIntsRef(BytesRef input, IntsRefBuilder scratch) {
-    scratch.clear();
+    scratch.growNoCopy(input.length);
     for (int i = 0; i < input.length; i++) {
-      scratch.append(input.bytes[i + input.offset] & 0xFF);
+      scratch.setIntAt(i, input.bytes[i + input.offset] & 0xFF);
     }
+    scratch.setLength(input.length);
     return scratch.get();
   }