You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/03/11 21:05:52 UTC

(lucene) branch branch_10x updated: Replace BigInteger allocation in StringHelper.idToString with HexFormat (#15807)

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

dweiss 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 cefbf049d67 Replace BigInteger allocation in StringHelper.idToString with HexFormat (#15807)
cefbf049d67 is described below

commit cefbf049d678e2ca114d083bf21a78f69efed283
Author: Sagar <99...@users.noreply.github.com>
AuthorDate: Wed Mar 11 14:05:26 2026 -0700

    Replace BigInteger allocation in StringHelper.idToString with HexFormat (#15807)
    
    * Replace BigInteger allocation in StringHelper.idToString with HexFormat
    
    * Add changelog
---
 lucene/CHANGES.txt                                            | 2 ++
 lucene/core/src/java/org/apache/lucene/util/StringHelper.java | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 3a77285294f..7cc955251d3 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -77,6 +77,8 @@ Other
 * GITHUB#15783: Refactor QuantizedVectorsReader to be able to access lucene 104 quantized values through this API.
   (Ignacio Vera)
 
+* GITHUB#15807: Replace BigInteger allocation in StringHelper.idToString with HexFormat. (Sagar Upadhyaya)
+
 * GITHUB#15799: Exclude JNA Cleaner from thread leak detection by LuceneTestCase. (Alan Woodward)
 
 ======================= Lucene 10.4.0 =======================
diff --git a/lucene/core/src/java/org/apache/lucene/util/StringHelper.java b/lucene/core/src/java/org/apache/lucene/util/StringHelper.java
index 002d6dd2786..e058fb1e886 100644
--- a/lucene/core/src/java/org/apache/lucene/util/StringHelper.java
+++ b/lucene/core/src/java/org/apache/lucene/util/StringHelper.java
@@ -21,6 +21,7 @@ import java.math.BigInteger;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.HexFormat;
 import java.util.Properties;
 
 /**
@@ -342,7 +343,7 @@ public abstract class StringHelper {
       return "(null)";
     } else {
       StringBuilder sb = new StringBuilder();
-      sb.append(new BigInteger(1, id).toString(Character.MAX_RADIX));
+      sb.append(HexFormat.of().formatHex(id));
       if (id.length != ID_LENGTH) {
         sb.append(" (INVALID FORMAT)");
       }