RFR 8222955 : Optimize String.replace(CharSequence, CharSequence) for Latin1 encoded strings
peter.levart at gmail.com
Tue Apr 30 07:36:12 UTC 2019
On 4/30/19 6:43 AM, Ivan Gerasimov wrote:
> I used StringConcatHelper.newArray() to avoid bringing Unsafe into
> In the StringLatin1.replace(), the newly allocated array is guaranteed
> to be filled up, and the filling code should never throw, so I believe
> using uninitialized arrays here is justified.
...even if it throwed (and throwing in the middle could be provoked with
for example Thread.stop), the allocated array would not escape the
function. So the method just has to guarantee that when it returns
normally, all bytes of array have been overwritten and that the array is
published securely (i.e. assigned to a final field of an object who's
reference is returned from the method)...
More information about the core-libs-dev