On Fri, 22 Sep 2023 11:53:18 GMT, Andriy Plokhotnyuk <d...@openjdk.org> wrote:

>> 1. Reduce duplicate stringSize code
>> 2. Move java.lang.StringLatin1.getChars to 
>> jdk.internal.util.DecimalDigits::getCharLatin1,not only java.lang, other 
>> packages also need to use this method
>
> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 115:
> 
>> 113:         }
>> 114:         return 10 + d;
>> 115:     }
> 
> @wenshao How about of using 
> [this](https://github.com/plokhotnyuk/jsoniter-scala/blob/6b72cf75ad7f53e8a285d512009d164c3eabbb3a/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonWriter.scala#L2367-L2369)
>  trick to avoid multiplications in a loop?

This implementation is copied from Integer.stringSize. In 2015, @Shipilev 
modified the table lookup to the current implementation. In actual testing, 
this algorithm is faster.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15699#discussion_r1334411468

Reply via email to