{"id":299072,"date":"2020-02-21T15:00:37","date_gmt":"2020-02-21T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299072"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-21T15:00:37","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299072","title":{"rendered":"\u041c\u043e\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u043e\u043c\u0435\u0440 5"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488874\/\">\n<p><em>\u0410 \u044f \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u043b, \u044f \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u043b SJ<br \/>  \u041e\u043f\u044f\u0442\u044c, \u043e\u043f\u044f\u0442\u044c, \u043e\u043f\u044f\u0442\u044c\u2026<br \/>  \u041e\u0445, \u043a\u0430\u043a \u043d\u0430\u043c\u0430\u044f\u043b\u0441\u044f \u044f \u0441 \u0442\u043e\u0431\u043e\u0439<br \/>  \u041c\u043e\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u043e\u043c\u0435\u0440 \u043f\u044f\u0442\u044c.<br \/>  <\/em><br \/>  \u041a\u0440\u0443\u0442\u0438\u043b\u043e\u0441\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e <del>\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439<\/del> \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 <code>StringJoiner<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u0445, \u0432\u0441\u0442\u0430\u0432\u0448\u0438\u0445 \u043d\u0430 \u043c\u043e\u0451\u043c \u043f\u0443\u0442\u0438. \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0441\u0447\u043b\u0435\u043d\u0451\u043d\u043a\u0430 \u0438 \u043a\u0438\u0448\u043a\u0438, \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u043e\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u0434\u0435\u0442\u0435\u0439 \u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u0438\u0446.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h4 id=\"postanovka-zadachi\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u0436\u0430\u0432\u0430-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (<a href=\"https:\/\/openjdk.java.net\/jeps\/254\" rel=\"nofollow\">JEP 254<\/a>), \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 Java 9. \u041f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e \u044d\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a: \u0432 \u0441\u0442\u0430\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 (\u0434\u043e 8 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e) \u0432\u043d\u0443\u0442\u0440\u0438 <code>java.lang.String<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 <code>char[]<\/code>, \u043f\u043e\u0441\u043b\u0435 \u2014 \u0432 \u0432\u0438\u0434\u0435 <code>byte[]<\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0432\u0441\u0435 \u0437\u043d\u0430\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a ASCII (\u0442. \u0435. \u0434\u043b\u044f \u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e 1 \u0431\u0430\u0439\u0442\u0430). \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438 \u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043e <a href=\"https:\/\/www.youtube.com\/watch?v=v2XLg4SvCF8\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0422\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0441\u044f <code>java.lang.AbstractStringBuilder<\/code>, \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>java.lang.StringBuilder<\/code> \u0438 <code>java.lang.StringBuffer<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0441 <code>java.util.StringJoiner<\/code>-\u043e\u043c \u0432\u0441\u0451 \u0438\u043d\u0430\u0447\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <a href=\"https:\/\/youtu.be\/5Y0Alqb9H_I?t=310\" rel=\"nofollow\">Java 9<\/a> \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>toString()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">String delimiter = this.delimiter; char[] chars = new char[this.len + addLen];  \/\/ !!! int k = getChars(this.prefix, chars, 0); if (size &gt; 0) {   k += getChars(elts[0], chars, k);        \/\/ \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c byte[] -&gt; char[]    for(int i = 1; i &lt; size; ++i) {     k += getChars(delimiter, chars, k);     k += getChars(elts[i], chars, k);   } }  k += getChars(this.suffix, chars, k); return new String(chars);                    \/\/ \u0441\u0436\u0438\u043c\u0430\u0435\u043c char[] -&gt; byte[]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0437\u043d\u0430\u043a\u0438, \u043d\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 ASCII (\u0437\u043d\u0430\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d 2 \u0431\u0430\u0439\u0442\u0430\u043c\u0438), \u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u0430. \u041d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435? \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0432\u0435\u0449\u044c: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 <code>byte[]<\/code> \u0438\u0437 \u0441\u0436\u0430\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e <code>char[]<\/code> (\u043f\u0440\u0438 \u0447\u0451\u043c \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 0), \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0443\u0441\u0435\u043a\u0430\u0435\u0442\u0441\u044f. \u0412\u0441\u0451 \u044d\u0442\u043e \u0441\u0442\u041e\u0438\u0442. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"pervaya-krov\">\u041f\u0435\u0440\u0432\u0430\u044f \u043a\u0440\u043e\u0432\u044c<\/h4>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c <code>StringJoiner<\/code> (JDK 14, \u043c\u0430\u043b\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0443\u0449\u0435\u043d\u044b):<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class StringJoiner {   private final String prefix;   private final String delimiter;   private final String suffix;    \/** Contains all the string components added so far. *\/   private String[] elts;    \/** The number of string components added so far. *\/   private int size;    \/** Total length in chars so far, excluding prefix and suffix. *\/   private int len;    \/\/ ...   public StringJoiner(CharSequence delimiter,                         CharSequence prefix,                         CharSequence suffix) {     \/\/ ...     this.prefix = prefix.toString();     this.delimiter = delimiter.toString();     this.suffix = suffix.toString();   }    \/\/ ...   public StringJoiner add(CharSequence newElement) {     final String elt = String.valueOf(newElement);     if (elts == null) {       elts = new String[8];     } else {       if (size == elts.length)         elts = Arrays.copyOf(elts, 2 * size);       len += delimiter.length();     }     len += elt.length();     elts[size++] = elt;     return this;   }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0448\u0435\u0441\u0442\u0435\u0440\u0451\u043d\u043a\u0438 \u043a\u0440\u0443\u043f\u043d\u044b\u043c \u043f\u043b\u0430\u043d\u043e\u043c: \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432, \u0438\u0445 \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0435 <code>len<\/code>, \u0430 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u2014 \u0432 \u043f\u043e\u043b\u0435 <code>size<\/code>. \u042d\u0442\u0438 \u043f\u043e\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>toString()<\/code> \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043b\u0430\u0442\u0438\u043d\u0438\u0446\u0435. \u0422\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u0432\u0435\u0442\u043a\u0438: \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e <code>char[]<\/code>) \u0438 &quot;\u0441\u0436\u0430\u0442\u0443\u044e&quot; (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e <code>byte[]<\/code>) \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u043b\u043e\u0431: \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0444\u043b\u0430\u0433 <code>allLatin1<\/code> \u0438 \u043f\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class StringJoiner {   private boolean allLatin1;    public StringJoiner(CharSequence delimiter,                       CharSequence prefix,                       CharSequence suffix) {     \/\/ ...     this.allLatin1 = this.prefix.isLatin1() &amp;&amp; this.delimiter.isLatin1() &amp;&amp; this.suffix.isLatin1();   }    public StringJoiner add(CharSequence newElement) {     final String elt = String.valueOf(newElement);     \/\/...     this.allLatin1 &amp;= elt.isLatin1();     return this;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430, \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e :). \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0435\u0442\u043e\u0434 <code>toString()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public String toString() {   final String[] elts = this.elts;   if (elts == null &amp;&amp; emptyValue != null) {     return emptyValue;   }   final int size = this.size;   final int addLen = prefix.length() + suffix.length();   if (addLen == 0) {     compactElts();     return size == 0 ? &quot;&quot; : elts[0];   }   if (allLatin1) {     return bytesToString(elts, size, addLen);   }   return charsToString(elts, size, addLen); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u043d\u044f\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0435\u0445\u0430\u043b\u0430 \u0432 <code>charsToString()<\/code>, \u0430 \u0435\u0451 \u043d\u0435\u0437\u0430\u043a\u043e\u043d\u043d\u043e\u0440\u043e\u0436\u0434\u0451\u043d\u043d\u044b\u043c \u0431\u0440\u0430\u0442\u043e\u043c-\u0431\u043b\u0438\u0437\u043d\u0435\u0446\u043e\u043c \u0441\u0442\u0430\u043b <code>bytesToString()<\/code>, \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>byte[]<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">private String bytesToString(String[] elts, int size, int addLen) {   final byte[] bytes = new byte[len + addLen];   int k = getBytes(prefix, bytes, 0);   if (size &gt; 0) {     final String delimiter = this.delimiter;     k += getBytes(elts[0], bytes, k);     for (int i = 1; i &lt; size; i++) {       k += getBytes(delimiter, bytes, k);       k += getBytes(elts[i], bytes, k);     }   }   getBytes(suffix, bytes, k);   return new String(bytes); }  @SuppressWarnings(&quot;deprecation&quot;) private static int getBytes(String s, byte[] bytes, int start) {   int len = s.length();   s.getBytes(0, len, bytes, start);   return len; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0442\u0443\u043f\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 <code>char[]<\/code> \u043d\u0430 <code>byte[]<\/code> \u0438 \u043e\u0434\u043d\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435. \u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ JDK 14 public final class String {    boolean isLatin1() {     return COMPACT_STRINGS &amp;&amp; coder == LATIN1;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0446\u0446\u043e, \u0447\u0442\u043e <code>StringJoiner<\/code> \u0436\u0438\u0432\u0451\u0442 \u0432 <code>java.util<\/code>, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>String.isLatin1()<\/code> \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 <code>java.lang<\/code>. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u2014 \u0442\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ JDK 11 public final class String {    private boolean isLatin1() {                   \/\/ private !     return COMPACT_STRINGS &amp;&amp; coder == LATIN1;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u0441\u0442\u0430\u0432 \u043d\u0430 \u044d\u0442\u0443 \u0434\u043e\u0440\u043e\u0436\u043a\u0443 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0435\u0449\u0451 \u0440\u0430\u0437?<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class String {    public boolean isLatin1() {                    \/\/ \u0430 \u0445*\u043b\u0438?     return COMPACT_STRINGS &amp;&amp; coder == LATIN1;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0432\u044b\u0437\u0432\u0430\u043d. \u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0442\u0447, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b\u0439 <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064580.html\" rel=\"nofollow\">\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0438\u0441\u044c\u043c\u043e\u043c \u0438 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0430\u043c\u0438<\/a> \u0432 core-libs-dev (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0430\u043c \u043f\u0430\u0442\u0447 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0438\u0441\u044c\u043c\u0430).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0427\u0451 \u0442\u0430\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e?<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u0430\u043c\u043e\u043f\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a (<a href=\"https:\/\/github.com\/stsypanov\/strings\/blob\/master\/src\/jmh\/java\/tsypanov\/strings\/join\/StringJoinerBenchmark.java\" rel=\"nofollow\">\u0442\u0435\u043b\u043e<\/a>, <a href=\"https:\/\/github.com\/stsypanov\/strings\/blob\/master\/src\/main\/java\/tsypanov\/strings\/source\/string\/Joiner.java\" rel=\"nofollow\">\u0443\u0442\u0438\u043b\u0438\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0434\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 latin = true (\u0432\u0441\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f latin1, \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u043a\u043e\u043c):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">                       count length         Original  Patched          Units sj                         1      1     26.7 \u00b1   1.3     38.2 \u00b1   1.1  ns\/op ! sj                         1      5     27.4 \u00b1   0.0     40.5 \u00b1   2.2  ns\/op ! sj                         1     10     29.6 \u00b1   1.9     38.4 \u00b1   1.9  ns\/op ! sj                         1    100     61.1 \u00b1   6.9     47.6 \u00b1   0.6  ns\/op sj                         5      1     91.1 \u00b1   6.7     83.6 \u00b1   2.0  ns\/op sj                         5      5     96.1 \u00b1  10.7     85.6 \u00b1   1.1  ns\/op sj                         5     10    105.5 \u00b1  14.3     84.7 \u00b1   1.1  ns\/op sj                         5    100    266.6 \u00b1  30.1    139.6 \u00b1  14.0  ns\/op sj                        10      1    190.7 \u00b1  23.0    162.0 \u00b1   2.9  ns\/op sj                        10      5    200.0 \u00b1  16.9    167.5 \u00b1  11.0  ns\/op sj                        10     10    216.4 \u00b1  12.4    164.8 \u00b1   1.7  ns\/op sj                        10    100    545.3 \u00b1  49.7    282.2 \u00b1  12.0  ns\/op sj                       100      1   1467.0 \u00b1  90.3   1302.0 \u00b1  18.5  ns\/op sj                       100      5   1491.8 \u00b1 166.2   1493.0 \u00b1 135.4  ns\/op sj                       100     10   1768.8 \u00b1 160.6   1760.8 \u00b1 111.4  ns\/op sj                       100    100   3654.3 \u00b1 113.1   3120.9 \u00b1 175.9  ns\/op sj:\u00b7gc.alloc.rate.norm     1      1    120.0 \u00b1   0.0    120.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     1      5    128.0 \u00b1   0.0    120.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     1     10    144.0 \u00b1   0.0    136.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     1    100    416.0 \u00b1   0.0    312.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     5      1    144.0 \u00b1   0.0    136.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     5      5    200.0 \u00b1   0.0    168.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     5     10    272.0 \u00b1   0.0    216.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm     5    100   1632.0 \u00b1   0.0   1128.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm    10      1    256.0 \u00b1   0.0    232.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm    10      5    376.0 \u00b1   0.0    312.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm    10     10    520.0 \u00b1   0.0    408.0 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm    10    100   3224.1 \u00b1   0.0   2216.1 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm   100      1   1760.2 \u00b1  14.9   1544.2 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm   100      5   2960.3 \u00b1  14.9   2344.2 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm   100     10   4440.4 \u00b1   0.0   3336.3 \u00b1   0.0   B\/op sj:\u00b7gc.alloc.rate.norm   100    100  31449.3 \u00b1  12.2  21346.7 \u00b1  14.7   B\/op<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f 1 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0447\u0442\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e: \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b, \u0430 \u0438\u0445 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c. \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 &quot;\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0441\u0442\u0438&quot; (\u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435, \u043f\u043e\u043a\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0434\u043e\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e).<\/p>\n<p>  <\/p>\n<h4 id=\"nabivaem-shishki\">\u041d\u0430\u0431\u0438\u0432\u0430\u0435\u043c \u0448\u0438\u0448\u043a\u0438<\/h4>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u043b, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0437\u043a\u043e\u0435 \u0438 \u043f\u043e\u0434\u0437\u0430\u0442\u044b\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u043d\u0435 \u043c\u0438\u043d\u043e\u0432\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442: \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 <code>String.isLatin1()<\/code> \u043d\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c, \u0430 \u043d\u0430\u043c\u0443\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">package java.lang;  public class StringHelper {   public static boolean isLatin1(String str) {     return str.isLatin1();   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0438 \u0424\u043e\u0440\u0430 <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064587.html\" rel=\"nofollow\">\u0437\u0430\u0431\u0440\u0430\u043a\u043e\u0432\u0430\u043b \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/a>:<\/p>\n<p>  <\/p>\n<blockquote><p>You can not change the implementation anymore, by example if instead of having a split between latin1 and non latin1, we decide in the future to split between utf8 and non utf8.<\/p>\n<p>  If you want to optimize StringJoiner, the best way to do it is to use the shared secret mechanism so a java.util class can see implementation details of a java.lang class without exposing those details publicly. As an example, take a look to EnumSet and its implementations.<\/p><\/blockquote>\n<p>\u0414\u043e\u0432\u043e\u0434\u044b \u0432\u0435\u0441\u043a\u0438\u0435: \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u044e\u0442 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043b\u0438\u043d\u0438\u0438 latin1 \/ \u043d\u0435 latin1, \u0442\u043e \u0438\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 UTF-8 \/ \u043d\u0435 UTF-8). \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043e\u0439\u0442\u0438 \u043c\u0435\u0436\u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0435 \u043f\u0440\u0435\u0433\u0440\u0430\u0434\u044b \u2014 \u0442\u0430\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <code>SharedSecrets<\/code>.<\/p>\n<p>  <\/p>\n<h4 id=\"glubzhe-eschyo-glubzhe\">\u0413\u043b\u0443\u0431\u0436\u0435! \u0415\u0449\u0451 \u0433\u043b\u0443\u0431\u0436\u0435!<\/h4>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0448 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u2014 <code>jdk.internal.access.SharedSecrets<\/code> (\u0432 \u0440\u0430\u043d\u043d\u0438\u0445 \u0438\u0437\u0434\u0430\u043d\u0438\u044f\u0445 \u0444\u0438\u0433\u0443\u0440\u0430\u043d\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a <code>jdk.internal.misc.SharedSecrets<\/code>). \u0427\u0438\u0442\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/** A repository of &quot;shared secrets&quot;, which are a mechanism for     calling implementation-private methods in another package without     using reflection. A package-private class implements a public     interface and provides the ability to call package-private methods     within that package; the object implementing that interface is     provided through a third package to which access is restricted.     This framework avoids the primary disadvantage of using reflection     for this purpose, namely the loss of compile-time checking. *\/<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0431\u043d\u0430\u0434\u0451\u0436\u0438\u0432\u0430\u044e\u0449\u0435, \u043f\u0440\u0430\u0432\u0434\u0430, \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u0441\u043c\u043e\u0433 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c &quot;\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0441\u0442\u044c&quot; \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064628.html\" rel=\"nofollow\">\u0441\u043e\u0432\u0435\u0442\u0443<\/a> \u0420\u0435\u043c\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u043c\u0443:<\/p>\n<p>  <\/p>\n<blockquote><p>yes!<br \/>  crossing package boundary in a non public way is not free, but given that StringJoiner is used quite often (directly or indirectly using Collectors.joining()), it may worth the cost.<\/p><\/blockquote>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439. \u041f\u0435\u0440\u0432\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c &quot;\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0441\u0442\u044c&quot; \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">package jdk.internal.access;  public interface JavaLangStringAccess {   boolean isLatin1(String str); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f (\u043f\u043e\u043a\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438):<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class StringAccess implements jdk.internal.access.JavaLangStringAccess {   static {     SharedSecrets.setJavaLangStringAccess(new StringAccess());   }    private final Method isLatin1;    StringAccess() {     this.isLatin1 = initIsLatin1Method();   }    @Override   public boolean isLatin1(String str) {     try {       return (boolean) isLatin1.invoke(str);     } catch (IllegalAccessException | InvocationTargetException e) {       throw new RuntimeException(e);     }   }    private static Method initIsLatin1Method() {     try {       Method isLatin1 = String.class.getDeclaredMethod(&quot;isLatin1&quot;);       isLatin1.setAccessible(true);       return isLatin1;     } catch (NoSuchMethodException e) {       throw new Error(e);     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u0441\u0430\u043c <code>SharedSecrets<\/code> (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043b\u0435\u043d\u0438\u0432\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>StringAccess<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public class SharedSecrets {   private static final Unsafe unsafe = Unsafe.getUnsafe();    private static JavaLangStringAccess javaLangStringAccess;    \/\/ ...    public static JavaLangStringAccess getJavaLangStringAccess() {     if (javaLangStringAccess == null) {       unsafe.ensureClassInitialized(StringAccess.class);     }     return javaLangStringAccess;   }    public static void setJavaLangStringAccess(JavaLangStringAccess stringAccess) {     javaLangStringAccess = stringAccess;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>StringJoiner.add()<\/code> \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 \u0432 <code>JavaLangStringAccess.isLatin1()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class StringJoiner {   private boolean allLatin1;    public StringJoiner add(CharSequence newElement) {     final String elt = String.valueOf(newElement);     \/\/...     this.allLatin1 &amp;= isLatin1(elt);     return this;   }    private static boolean isLatin1(String str) {     return SharedSecrets.getJavaLangStringAccess().isLatin1(str);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u0435\u0449\u0451 \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0432\u0435\u0434\u044c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f \u2014 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 \u043d\u0435 \u0438\u0437 \u0434\u0435\u0448\u0451\u0432\u044b\u0445. \u0422\u0430\u043a\u0436\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443 \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a, \u0442. \u043a. \u0442\u0430\u043c \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0435\u0449\u0451 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 &quot;\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0441\u0442\u0438&quot;. \u0412\u044b\u0448\u0435 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0435\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class StringJoiner {   private boolean allLatin1;    public StringJoiner(CharSequence delimiter,                       CharSequence prefix,                       CharSequence suffix) {     \/\/ ...     this.allLatin1 = isLatin1(this.prefix) &amp;&amp; isLatin1(this.delimiter) &amp;&amp; isLatin1(this.suffix);   }    public StringJoiner add(CharSequence newElement) {     final String elt = String.valueOf(newElement);     \/\/...     this.allLatin1 &amp;= isLatin1(elt);     return this;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c 10 \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a. \u0423\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f <code>allLatin1<\/code> \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <code>false<\/code>, \u0434\u0435\u043b\u0430\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0432\u0435\u0434\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. \u0412\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043e\u0442\u043a\u0430\u0442\u0430 \u043a <code>char[]<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438: \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u043e\u043b\u0435 <code>allLatin1<\/code> \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>toString()<\/code>. \u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0436\u0435 \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0435\u0440\u043d\u0443\u0442\u044c <code>false<\/code>, \u0447\u0442\u043e \u0441\u0433\u043b\u0430\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">private static boolean allLatin1(String[] strings, int size) {   for (int i = 0; i &lt; size; i++) {     String str = strings[i];     if (!SharedSecrets.getJavaLangStringAccess().isLatin1(str)) {       return false;     }   }   return true; }  private boolean psdLatin1() {   return SharedSecrets.getJavaLangStringAccess().isLatin1(delimiter)       &amp;&amp; SharedSecrets.getJavaLangStringAccess().isLatin1(prefix)       &amp;&amp; SharedSecrets.getJavaLangStringAccess().isLatin1(suffix) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c <code>toString()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public String toString() {   final String[] elts = this.elts;   if (elts == null &amp;&amp; emptyValue != null) {     return emptyValue;   }   final int size = this.size;   final int addLen = prefix.length() + suffix.length();   if (addLen == 0) {     compactElts();     return size == 0 ? &quot;&quot; : elts[0];   }   if (psdLatin1() &amp;&amp; allLatin1(elts, size)) {     return bytesToString(elts, size, addLen);   }   return charsToString(elts, size, addLen); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u043e\u043b\u043a \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u043e\u043b\u044c &#8212; \u044d\u0442\u043e \u0431\u043e\u043b\u044c, \u043a\u0430\u043a \u0435\u0451 \u0442\u044b \u043d\u0435 \u043d\u0430\u0437\u043e\u0432\u0438&#8230;<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">Benchmark      count    latin  len        Original          Patched sj                 1     true    1    26.9 \u00b1   0.7     48.8 \u00b1   2.2 ns\/op ! sj                 1     true    5    30.5 \u00b1   1.0     46.1 \u00b1   2.1 ns\/op ! sj                 1     true   10    31.2 \u00b1   0.6     47.3 \u00b1   1.3 ns\/op ! sj                 1     true  100    62.5 \u00b1   3.3     79.9 \u00b1   4.8 ns\/op ! sj                 5     true    1    78.2 \u00b1   1.6    110.3 \u00b1   2.9 ns\/op ! sj                 5     true    5    94.2 \u00b1   8.7    116.6 \u00b1   0.7 ns\/op ! sj                 5     true   10    95.3 \u00b1   6.9    100.1 \u00b1   0.4 ns\/op sj                 5     true  100   188.0 \u00b1  10.2    136.0 \u00b1   0.4 ns\/op sj                10     true    1   160.3 \u00b1   4.5    172.9 \u00b1   0.8 ns\/op sj                10     true    5   169.0 \u00b1   4.7    180.2 \u00b1   9.1 ns\/op sj                10     true   10   205.7 \u00b1  16.4    182.7 \u00b1   1.1 ns\/op sj                10     true  100   366.5 \u00b1  17.0    284.5 \u00b1   3.1 ns\/op sj               100     true    1  1117.6 \u00b1  11.1   2123.7 \u00b1  11.1 ns\/op ! sj               100     true    5  1270.7 \u00b1  40.2   2163.6 \u00b1  12.4 ns\/op ! sj               100     true   10  1364.4 \u00b1  14.0   2283.8 \u00b1  16.1 ns\/op ! sj               100     true  100  3592.9 \u00b1 164.8   3535.2 \u00b1  29.9 ns\/op  sj                 1    false    1    35.6 \u00b1   1.2     59.1 \u00b1   3.0 ns\/op ! sj                 1    false    5    39.3 \u00b1   1.2     52.6 \u00b1   2.5 ns\/op ! sj                 1    false   10    42.2 \u00b1   1.6     53.6 \u00b1   0.3 ns\/op ! sj                 1    false  100    70.5 \u00b1   1.8     86.4 \u00b1   0.4 ns\/op ! sj                 5    false    1    89.0 \u00b1   3.5    102.2 \u00b1   1.0 ns\/op ! sj                 5    false    5    87.6 \u00b1   0.7    106.5 \u00b1   1.2 ns\/op ! sj                 5    false   10   109.0 \u00b1   5.6    116.5 \u00b1   1.2 ns\/op ! sj                 5    false  100   324.0 \u00b1  16.5    221.9 \u00b1   0.5 ns\/op sj                10    false    1   183.9 \u00b1   5.9    204.7 \u00b1   5.5 ns\/op ! sj                10    false    5   198.7 \u00b1   9.7    202.4 \u00b1   1.5 ns\/op ! sj                10    false   10   196.7 \u00b1   6.9    226.7 \u00b1   6.4 ns\/op ! sj                10    false  100   535.8 \u00b1   2.3    553.0 \u00b1   5.6 ns\/op ! sj               100    false    1  1674.6 \u00b1 122.1   1940.8 \u00b1  16.2 ns\/op ! sj               100    false    5  1791.9 \u00b1  58.1   2158.1 \u00b1  12.0 ns\/op ! sj               100    false   10  2124.1 \u00b1 193.3   2364.0 \u00b1  25.2 ns\/op ! sj               100    false  100  4323.4 \u00b1  29.2   4675.5 \u00b1  11.8 ns\/op !  sj:\u00b7gc.a.r.n       1     true    1   120.0 \u00b1   0.0    120.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1     true    5   128.0 \u00b1   0.0    120.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1     true   10   144.0 \u00b1   0.0    136.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1     true  100   416.0 \u00b1   0.0    312.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5     true    1   144.0 \u00b1   0.0    136.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5     true    5   200.0 \u00b1   0.0    168.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5     true   10   272.0 \u00b1   0.0    216.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5     true  100  1632.0 \u00b1   0.0   1128.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n      10     true    1   256.0 \u00b1   0.0    232.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n      10     true    5   376.0 \u00b1   0.0    316.8 \u00b1   4.9  B\/op sj:\u00b7gc.a.r.n      10     true   10   520.0 \u00b1   0.0    408.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n      10     true  100  3224.1 \u00b1   0.0   2236.9 \u00b1  21.2  B\/op sj:\u00b7gc.a.r.n     100     true    1  1748.1 \u00b1   4.0   1592.2 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100     true    5  2948.2 \u00b1   4.0   2392.3 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100     true   10  4444.3 \u00b1   4.0   3384.3 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100     true  100  1441.4 \u00b1   0.0  21385.4 \u00b1   0.0  B\/op  sj:\u00b7gc.a.r.n       1    false    1   144.0 \u00b1   0.0    144.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1    false    5   160.0 \u00b1   0.0    160.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1    false   10   184.0 \u00b1   0.0    184.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       1    false  100   640.0 \u00b1   0.0    640.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5    false    1   184.0 \u00b1   0.0    184.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5    false    5   280.0 \u00b1   0.0    280.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5    false   10   400.0 \u00b1   0.0    400.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n       5    false  100  2664.1 \u00b1   0.0   2664.1 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n      10    false    1   320.0 \u00b1   0.0    334.4 \u00b1   7.4  B\/op sj:\u00b7gc.a.r.n      10    false    5   520.0 \u00b1   0.0    520.0 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n      10    false   10   760.0 \u00b1   0.0    769.6 \u00b1   6.5  B\/op sj:\u00b7gc.a.r.n      10    false  100  5264.2 \u00b1   0.0   5273.8 \u00b1   6.5  B\/op sj:\u00b7gc.a.r.n     100    false    1  2204.2 \u00b1   4.0   2216.3 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100    false    5  4196.3 \u00b1   6.2   4216.4 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100    false   10  6696.5 \u00b1   5.4   6712.6 \u00b1   0.0  B\/op sj:\u00b7gc.a.r.n     100    false  100  1702.0 \u00b1   4.1  51714.4 \u00b1   0.0  B\/op<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u043e\u0431\u0449\u0438\u043c \u0438 \u043a\u0430\u0442\u0430\u0441\u0442\u0440\u043e\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c. \u041e\u043f\u044b\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0434\u0435\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f &quot;\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0441\u0442\u0438&quot; \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f \u043d\u0430\u043c \u043d\u0435 \u0442\u043e\u0432\u0430\u0440\u0438\u0449.<\/p>\n<p>  <\/p>\n<h4 id=\"replika-iz-zala\">\u0420\u0435\u043f\u043b\u0438\u043a\u0430 \u0438\u0437 \u0437\u0430\u043b\u0430<\/h4>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064698.html\" rel=\"nofollow\">\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0441\u044f<\/a> <a href=\"https:\/\/habr.com\/ru\/users\/lany\/\" class=\"user_link\">lany<\/a> \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439. \u042f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0438\u0435 (\u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434):<\/p>\n<p>  <\/p>\n<blockquote><p>Hello!<\/p>\n<p>  In many tests, I see little or no performance improvements. E.g.:<br \/>  stringJoiner 100 10 1768.8 \u00b1160.6 1760.8 \u00b1 111.4 ns\/op<\/p>\n<p>  How would you explain that this code change doesn&#8217;t improve the performance for given count and length?<\/p>\n<p>  <strong>Also, you are using <code>new String(bytes)<\/code> assuming that the platform charset is latin1-compatible. This is not always true, so your code would produce incorrect results depending on this setting. In general, decoding via charset is tons of extra work. Instead, I would experiment with pre-sized StringBuilder inside compactElts, instead of char[] array. While it does some extra checks, StringBuilder already can use the compact string representation, so if it&#8217;s properly pre-sized, no extra memory will be allocated.<\/strong><\/p>\n<p>  <strong>Finally, if you optimize for the case when X is true you should always benchmark what happens when X is false. It&#8217;s great that in some cases we see a speedup for latin1 strings. But what if not all of the strings are latin1?<\/strong> Is there any performance degradation? If yes, can we tolerate it?<\/p><\/blockquote>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0434\u044b\u0445. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u0434 <code>java.lang.String<\/code>, \u0442\u043e \u043d\u0430\u0439\u0434\u0451\u043c \u0442\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class String {   private final byte coder;   \/**   * @implNote   * The actual value for this field is injected by JVM. The static       &lt;--- !!!   * initialization block is used to set the value here to communicate   * that this static final field is not statically foldable, and to   * avoid any possible circular dependency during vm initialization.   *\/   static final boolean COMPACT_STRINGS;    static {     COMPACT_STRINGS = true;   }    boolean isLatin1() {     return COMPACT_STRINGS &amp;&amp; coder == LATIN1;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u043b\u0438 \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435 \u043f\u0440\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u0436\u0430\u0442\u0438\u0438 \u0441\u0442\u0440\u043e\u043a? \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>-XX:-CompactStrings<\/code> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>String.COMPACT_STRINGS<\/code> (\u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0431\u0435\u0437 \u0444\u043b\u0430\u0433\u043e\u0432 \u043e\u043d\u043e <code>true<\/code>). \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u2014 <code>String.COMPACT_STRINGS<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>false<\/code>. \u041f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e <\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public final class String {    boolean isLatin1() {     return COMPACT_STRINGS &amp;&amp; coder == LATIN1;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0442. \u0435. \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <code>isLatin1()<\/code> \u0432\u0435\u0440\u043d\u0443\u043b <code>true<\/code>, \u0442\u043e \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b. \u0412\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u043e\u0445\u043d\u0443\u0442\u044c: \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u043e\u0448\u043b\u0438 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>bytesToString()<\/code>, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u0441\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435, \u0430 \u0440\u0430\u0437 \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435, \u0442\u043e \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d \u0412\u041c. \u0415\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435:<\/p>\n<p>  <\/p>\n<blockquote><p><strong>In general, decoding via charset is tons of extra work. Instead, I would experiment with pre-sized StringBuilder inside compactElts, instead of char[] array. While it does some extra checks, StringBuilder already can use the compact string representation, so if it&#8217;s properly pre-sized, no extra memory will be allocated.<\/strong><\/p><\/blockquote>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u0432 \u043c\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f <code>char[]<\/code> \/ <code>byte[]<\/code>, \u043d\u043e \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 <code>StringBuilder<\/code>-\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u043c\u0443 \u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044e \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <code>java.lang<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0436\u0435, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public String toString() {   final String[] elts = this.elts;   if (elts == null &amp;&amp; emptyValue != null) {     return emptyValue;   }   final int size = this.size;   final int addLen = prefix.length() + suffix.length();   if (addLen == 0) {     compactElts();     return size == 0 ? &quot;&quot; : elts[0];   }   StringBuilder sb = new StringBuilder(len + addLen).append(prefix);   if (size &gt; 0) {     sb.append(elts[0]);     String delimiter = this.delimiter;     for (int i = 1; i &lt; size; i++) {       sb.append(delimiter).append(elts[i]);     }   }   return sb.append(suffix).toString(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430, \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430 \u043d\u0430\u0441 \u0441\u0442\u0430\u043d\u0434\u0440\u0430\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public AbstractStringBuilder append(String str) {   if (str == null) {     return appendNull();   }   int len = str.length();   ensureCapacityInternal(count + len);   putStringAt(count, str);   count += len;   return this; }  private final void putStringAt(int index, String str) {   if (getCoder() != str.coder()) {     inflate();   }   str.getBytes(value, index, coder); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0438\u0434\u0435\u0435 \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0430\u043b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">Benchmark     count  latin   len          Original     StringBuilder sj                1   true     1      26.9 \u00b1   0.7      33.4 \u00b1   0.2  ns\/op ! sj                1   true     5      30.5 \u00b1   1.0      33.0 \u00b1   0.1  ns\/op ! sj                1   true    10      31.2 \u00b1   0.6      34.3 \u00b1   0.3  ns\/op ! sj                1   true   100      62.5 \u00b1   3.3      44.4 \u00b1   0.1  ns\/op sj                5   true     1      78.2 \u00b1   1.6      87.8 \u00b1   0.8  ns\/op ! sj                5   true     5      94.2 \u00b1   8.7      88.2 \u00b1   0.9  ns\/op sj                5   true    10      95.3 \u00b1   6.9      91.6 \u00b1   0.6  ns\/op sj                5   true   100     188.0 \u00b1  10.2     126.1 \u00b1   0.7  ns\/op sj               10   true     1     160.3 \u00b1   4.5     177.6 \u00b1   0.8  ns\/op ! sj               10   true     5     169.0 \u00b1   4.7     179.4 \u00b1   1.0  ns\/op ! sj               10   true    10     205.7 \u00b1  16.4     189.5 \u00b1   1.2  ns\/op sj               10   true   100     366.5 \u00b1  17.0     290.0 \u00b1   0.8  ns\/op sj              100   true     1    1117.6 \u00b1  11.1    1563.8 \u00b1   2.8  ns\/op ! sj              100   true     5    1270.7 \u00b1  40.2    1592.4 \u00b1   4.0  ns\/op ! sj              100   true    10    1364.4 \u00b1  14.0    1773.7 \u00b1  57.7  ns\/op ! sj              100   true   100    3592.9 \u00b1 164.8    2899.2 \u00b1  51.0  ns\/op  sj                1  false     1      35.6 \u00b1   1.2      52.7 \u00b1   1.2  ns\/op ! sj                1  false     5      39.3 \u00b1   1.2      54.4 \u00b1   1.6  ns\/op ! sj                1  false    10      42.2 \u00b1   1.6      52.2 \u00b1   1.0  ns\/op ! sj                1  false   100      70.5 \u00b1   1.8      78.6 \u00b1   1.2  ns\/op ! sj                5  false     1      89.0 \u00b1   3.5     116.3 \u00b1   3.8  ns\/op ! sj                5  false     5      87.6 \u00b1   0.7     115.2 \u00b1   2.9  ns\/op ! sj                5  false    10     109.0 \u00b1   5.6     126.5 \u00b1   0.5  ns\/op ! sj                5  false   100     324.0 \u00b1  16.5     288.9 \u00b1   0.5  ns\/op  sj               10  false     1     183.9 \u00b1   5.9     261.2 \u00b1   7.7  ns\/op ! sj               10  false     5     198.7 \u00b1   9.7     253.3 \u00b1   6.7  ns\/op ! sj               10  false    10     196.7 \u00b1   6.9     274.3 \u00b1   7.0  ns\/op ! sj               10  false   100     535.8 \u00b1   2.3     677.3 \u00b1   6.4  ns\/op ! sj              100  false     1    1674.6 \u00b1 122.1    2212.5 \u00b1  32.2  ns\/op ! sj              100  false     5    1791.9 \u00b1  58.1    2492.8 \u00b1  30.9  ns\/op ! sj              100  false    10    2124.1 \u00b1 193.3    2611.7 \u00b1  17.5  ns\/op ! sj              100  false   100    4323.4 \u00b1  29.2    5501.3 \u00b1  21.1  ns\/op !  sj:\u00b7gc.a.r.n      1   true     1     120.0 \u00b1   0.0     144.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1   true     5     128.0 \u00b1   0.0     144.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1   true    10     144.0 \u00b1   0.0     160.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1   true   100     416.0 \u00b1   0.0     336.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n      5   true     1     144.0 \u00b1   0.0     160.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      5   true     5     200.0 \u00b1   0.0     192.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n      5   true    10     272.0 \u00b1   0.0     240.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n      5   true   100    1632.0 \u00b1   0.0    1152.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n     10   true     1     256.0 \u00b1   0.0     256.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n     10   true     5     376.0 \u00b1   0.0     336.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n     10   true    10     520.0 \u00b1   0.0     432.0 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n     10   true   100    3224.1 \u00b1   0.0    2240.1 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n    100   true     1    1748.1 \u00b1   4.0    1568.2 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n    100   true     5    2948.2 \u00b1   4.0    2368.2 \u00b1   0.0   B\/op  sj:\u00b7gc.a.r.n    100   true    10    4444.3 \u00b1   4.0    3364.3 \u00b1   4.0   B\/op  sj:\u00b7gc.a.r.n    100   true   100   31441.4 \u00b1   0.0   21365.1 \u00b1   4.1   B\/op   sj:\u00b7gc.a.r.n      1  false     1     144.0 \u00b1   0.0     192.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1  false     5     160.0 \u00b1   0.0     208.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1  false    10     184.0 \u00b1   0.0     240.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      1  false   100     640.0 \u00b1   0.0     784.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      5  false     1     184.0 \u00b1   0.0     240.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      5  false     5     280.0 \u00b1   0.0     349.6 \u00b1   2.4   B\/op ! sj:\u00b7gc.a.r.n      5  false    10     400.0 \u00b1   0.0     496.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n      5  false   100    2664.1 \u00b1   0.0    3216.1 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n     10  false     1     320.0 \u00b1   0.0     384.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n     10  false     5     520.0 \u00b1   0.0     624.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n     10  false    10     760.0 \u00b1   0.0     912.0 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n     10  false   100    5264.2 \u00b1   0.0    6320.3 \u00b1   0.0   B\/op ! sj:\u00b7gc.a.r.n    100  false     1    2204.2 \u00b1   4.0    2436.3 \u00b1   6.8   B\/op ! sj:\u00b7gc.a.r.n    100  false     5    4196.3 \u00b1   6.2    4832.4 \u00b1   6.6   B\/op ! sj:\u00b7gc.a.r.n    100  false    10    6696.5 \u00b1   5.4    7844.7 \u00b1   4.0   B\/op ! sj:\u00b7gc.a.r.n    100  false   100   51702.0 \u00b1   4.1   61838.6 \u00b1   6.2   B\/op !<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0423\u0432\u044b, \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435. \u041c\u044b \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a (\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0436\u0435\u0448\u044c \u043f\u0440\u043e \u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435), \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0445\u0443\u0436\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"prizrak-ash\">\u041f\u0440\u0438\u0437\u0440\u0430\u043a \u0410\u0428<\/h4>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u0434\u0430\u0432\u0448\u0438\u0445 \u043d\u0435\u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0414\u0451\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e <code>String.isLatin1()<\/code> \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439 \u2014 \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u0438\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>StringBuilder<\/code>-\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u0434\u0438\u0442, \u0447\u0435\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442. \u0412\u0441\u0451 \u043f\u0440\u043e\u043f\u0430\u043b\u043e? \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043d\u0435 \u0432\u0441\u0451.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064780.html\" rel=\"nofollow\">\u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f<\/a> \u0411\u0440\u0435\u043d\u0442 \u041a\u0440\u0438\u0441\u0442\u0438\u0430\u043d \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0441\u043e\u043d\u043e\u0439 \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e JEP 254:<\/p>\n<p>  <\/p>\n<blockquote><p>As a point of interest, some investigation of updating StringJoiner for CompactStrings was done a while back.<\/p>\n<p>  See <a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8148937\" rel=\"nofollow\">https:\/\/bugs.openjdk.java.net\/browse\/JDK-8148937<\/a><\/p><\/blockquote>\n<p>\u041f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0436\u0438\u0432\u0451\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0435\u0449\u0451 \u0441 2016 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c:<\/p>\n<p>  <\/p>\n<blockquote><p>This is seems to be a performance optimization, but it clashes with Compact Strings which now have to re-compress the resulting char[] array into byte[]. We may want to extend this mechanism by figuring out the coders for arguments, and creating byte[] with appropriate coder, then using a private String constructor that does not re-compress.<\/p><\/blockquote>\n<p>\u041f\u043e \u044d\u0442\u043e \u0436\u0435 \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c <a href=\"http:\/\/cr.openjdk.java.net\/~shade\/8148937\/webrev.01\/\" rel=\"nofollow\">\u0441\u0441\u044b\u043b\u043a\u0443<\/a> \u043d\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0418\u0437 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e:<br \/>  1) \u0412 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0443 <code>StringJoiner<\/code>-\u0430 \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>SharedSecrets<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 89 \u0432 &quot;\u0434\u043e&quot;)<br \/>  2) \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043e\u0440\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435. <code>char[]<\/code> \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u0432\u0441\u0435, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u044f\u0432\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435\/\u043d\u0435\u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a.<br \/>  3) \u0414\u043b\u044f \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0445 \u0431\u0430\u0440\u044c\u0435\u0440\u043e\u0432 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 <code>JavaLangAccess<\/code><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442, \u043a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0441\u0442\u0440\u043e\u043a\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0432\u044f\u0437\u043a\u0443 <code>SharedSecrets<\/code> -&gt; <code>JavaLangAccess<\/code> -&gt; <code>java.lang.System<\/code> \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c, \u0432\u0435\u0434\u044c <code>String.isLatin1()<\/code> \u0432\u0438\u0434\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0443 <code>System<\/code>!<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0445\u043e\u0434\u0438\u0442, \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u044d\u0442\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public interface JavaLangAccess {   \/\/...   boolean isLatin1(String str); }  public final class System {   \/\/...   public boolean isLatin1(String str) {     return str.isLatin1();   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0430 \u043d\u0435\u0442. \u041d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f. \u0415\u0449\u0451 \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0435\u043c \u0422\u0430\u0433\u0438\u0440\u0430:<\/p>\n<p>  <\/p>\n<blockquote><p>In general, decoding via charset is tons of extra work.<\/p><\/blockquote>\n<p>\u0425\u043c, \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>new String(byte[])<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">private String bytesToString(String[] elts, int size, int addLen) {   final byte[] bytes = new byte[len + addLen];   int k = getBytes(prefix, bytes, 0);   if (size &gt; 0) {     final String delimiter = this.delimiter;     k += getBytes(elts[0], bytes, k);     for (int i = 1; i &lt; size; i++) {       k += getBytes(delimiter, bytes, k);       k += getBytes(elts[i], bytes, k);     }   }   getBytes(suffix, bytes, k);   return new String(bytes); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0430 \u0432 \u043d\u0435\u0433\u043e-\u0442\u043e \u044f \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u2026 \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u0435 \u0432 \u0433\u043b\u0430\u0437\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public String(byte[] bytes) {   this(bytes, 0, bytes.length); }  public String(byte bytes[], int offset, int length) {   checkBoundsOffCount(offset, length, bytes.length);   StringCoding.Result ret = StringCoding.decode(bytes, offset, length); \/\/ \u0430\u0434\u042a   this.value = ret.value;   this.coder = ret.coder; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u044f\u043c\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 <code>new String(byte[])<\/code> \u043f\u0430\u0445\u043d\u0435\u0442 \u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u0423\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u043a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, <code>StringBuilder<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override @HotSpotIntrinsicCandidate public String toString() {   \/\/ Create a copy, don't share the array   return isLatin1()         ? StringLatin1.newString(value, 0, count)   \/\/ &lt;---        :  StringUTF16.newString(value, 0, count); }  final class StringLatin1 {   public static String newString(byte[] val, int index, int len) {     return new String(Arrays.copyOfRange(val, index, index + len), LATIN1);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043a\u043e\u043f\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0442. \u043a. \u043c\u0435\u0442\u043e\u0434 <code>StringBuilder.toString()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0441\u0430\u043c <code>StringBuilder<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>StringJoiner.toString()<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0432\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>StringLatin1.newString(byte[])<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">final class StringLatin1 {   public static String newString(byte[] val, int index, int len) {     byte[] copy = Arrays.copyOfRange(val, index, index + len);     return newString(copy);   }    public static String newString(byte[] val) {     return new String(val, LATIN1);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0451 \u0432\u043e\u0435\u0434\u0438\u043d\u043e, \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043c\u0435\u0440\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064799.html\" rel=\"nofollow\">\u043f\u0438\u0441\u044c\u043c\u043e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438<\/a> (\u043f\u0430\u0442\u0447 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u0443 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435). \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0442 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0447\u0442\u0438 \u0432\u0442\u0440\u043e\u0435!<\/p>\n<p>  <\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435: \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043d\u0430\u0448\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0430\u0442\u0447 \u0410\u0428. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u0438\u043c \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 JDK 14, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u043d\u0430\u043a\u0430\u0442\u0430\u043d\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">        latin cnt  len        Original            Mine             ASh  sj       true   1    1     27.7 \u00b1  1.2     22.1 \u00b1  0.2     19.7 \u00b1  0.2  ns\/op sj       true   1    5     27.7 \u00b1  0.1     22.3 \u00b1  0.0     19.8 \u00b1  0.0  ns\/op sj       true   1   10     29.0 \u00b1  0.6     23.2 \u00b1  0.0     20.1 \u00b1  0.1  ns\/op sj       true   1  100     51.4 \u00b1  0.1     31.4 \u00b1  0.1     32.9 \u00b1  0.1  ns\/op sj       true   5    1     71.1 \u00b1  0.4     64.9 \u00b1  0.3     53.8 \u00b1  0.1  ns\/op sj       true   5    5     79.5 \u00b1  0.3     65.5 \u00b1  0.3     54.8 \u00b1  0.1  ns\/op sj       true   5   10     81.2 \u00b1  0.3     67.7 \u00b1  0.2     56.1 \u00b1  0.1  ns\/op sj       true   5  100    150.0 \u00b1  0.4     86.5 \u00b1  0.5     78.5 \u00b1  0.3  ns\/op sj       true  10    1    145.5 \u00b1  0.7    142.5 \u00b1  0.4    127.1 \u00b1  0.5  ns\/op sj       true  10    5    160.0 \u00b1  0.8    145.6 \u00b1  0.2    130.8 \u00b1  0.3  ns\/op sj       true  10   10    165.6 \u00b1  0.4    150.8 \u00b1  0.3    138.9 \u00b1  0.4  ns\/op sj       true  10  100    340.2 \u00b1  1.2    189.3 \u00b1  0.4    175.2 \u00b1  0.7  ns\/op sj       true 100    1   1114.3 \u00b1 15.9   1372.7 \u00b1 53.0   1197.4 \u00b1 34.0  ns\/op ! sj       true 100    5   1184.2 \u00b1 18.5   1385.9 \u00b1 56.0   1159.0 \u00b1 32.3  ns\/op sj       true 100   10   1345.8 \u00b1 13.9   1369.0 \u00b1  2.7   1233.5 \u00b1 32.9  ns\/op sj       true 100  100   3156.1 \u00b1 19.1   1844.1 \u00b1  4.1   1727.9 \u00b1 37.6  ns\/op  sj      false   1    1     33.5 \u00b1  0.4     34.9 \u00b1  0.1     19.6 \u00b1  0.0  ns\/op sj      false   1    5     33.3 \u00b1  0.3     35.9 \u00b1  0.1     20.1 \u00b1  0.1  ns\/op sj      false   1   10     33.8 \u00b1  0.1     35.9 \u00b1  0.1     20.6 \u00b1  0.0  ns\/op sj      false   1  100     57.5 \u00b1  0.2     58.3 \u00b1  0.1     39.6 \u00b1  0.1  ns\/op sj      false   5    1     82.9 \u00b1  0.5     82.0 \u00b1  0.8     64.2 \u00b1  1.3  ns\/op sj      false   5    5     86.0 \u00b1  0.5     84.8 \u00b1  0.9     66.6 \u00b1  0.8  ns\/op sj      false   5   10     96.9 \u00b1  0.5     92.5 \u00b1  0.6     76.9 \u00b1  0.7  ns\/op sj      false   5  100    224.2 \u00b1  0.6    226.7 \u00b1  0.7    125.1 \u00b1  0.6  ns\/op sj      false  10    1    165.7 \u00b1  0.9    167.6 \u00b1  3.2    152.1 \u00b1  1.0  ns\/op sj      false  10    5    178.4 \u00b1  0.7    179.6 \u00b1  2.1    163.7 \u00b1  0.9  ns\/op sj      false  10   10    191.7 \u00b1  0.9    195.9 \u00b1  2.2    172.5 \u00b1  0.8  ns\/op sj      false  10  100    534.4 \u00b1  1.4    534.5 \u00b1  1.3    305.2 \u00b1  1.1  ns\/op sj      false 100    1   1435.9 \u00b1  9.5   1428.2 \u00b1  3.2   1333.0 \u00b1  4.7  ns\/op sj      false 100    5   1618.5 \u00b1 14.3   1595.2 \u00b1  3.7   1379.7 \u00b1 10.4  ns\/op sj      false 100   10   1898.1 \u00b1  9.4   1860.8 \u00b1  4.7   1531.5 \u00b1 13.7  ns\/op sj      false 100  100   4247.4 \u00b1 60.7   4150.1 \u00b1  9.1   2423.8 \u00b1 11.9  ns\/op  g.a.r.n  true   1    1    124.0 \u00b1  4.0     96.0 \u00b1  0.0     96.0 \u00b1  0.0   B\/op g.a.r.n  true   1    5    128.0 \u00b1  0.0     96.0 \u00b1  0.0     96.0 \u00b1  0.0   B\/op g.a.r.n  true   1   10    144.0 \u00b1  0.0    104.0 \u00b1  0.0    104.0 \u00b1  0.0   B\/op g.a.r.n  true   1  100    416.0 \u00b1  0.0    192.0 \u00b1  0.0    192.0 \u00b1  0.0   B\/op g.a.r.n  true   5    1    144.0 \u00b1  0.0    104.0 \u00b1  0.0     96.0 \u00b1  0.0   B\/op g.a.r.n  true   5    5    200.0 \u00b1  0.0    120.0 \u00b1  0.0    120.0 \u00b1  0.0   B\/op g.a.r.n  true   5   10    272.0 \u00b1  0.0    144.0 \u00b1  0.0    144.0 \u00b1  0.0   B\/op g.a.r.n  true   5  100   1632.0 \u00b1  0.0    600.0 \u00b1  0.0    592.0 \u00b1  0.0   B\/op g.a.r.n  true  10    1    256.0 \u00b1  0.0    192.0 \u00b1  0.0    184.0 \u00b1  0.0   B\/op g.a.r.n  true  10    5    376.0 \u00b1  0.0    232.0 \u00b1  0.0    224.0 \u00b1  0.0   B\/op g.a.r.n  true  10   10    520.0 \u00b1  0.0    280.0 \u00b1  0.0    272.0 \u00b1  0.0   B\/op g.a.r.n  true  10  100   3224.1 \u00b1  0.0   1184.0 \u00b1  0.0   1168.0 \u00b1  0.0   B\/op g.a.r.n  true 100    1   1752.1 \u00b1  5.4   1328.2 \u00b1  5.4   1244.1 \u00b1  9.5   B\/op g.a.r.n  true 100    5   2952.2 \u00b1  5.4   1728.2 \u00b1  5.4   1627.3 \u00b1  7.6   B\/op g.a.r.n  true 100   10   4444.4 \u00b1  4.0   2216.2 \u00b1  0.0   2140.2 \u00b1  9.5   B\/op g.a.r.n  true 100  100  31445.6 \u00b1  4.0  11216.7 \u00b1  0.0  11135.0 \u00b1  9.3   B\/op  g.a.r.n false   1    1    144.0 \u00b1  0.0    144.0 \u00b1  0.0     96.0 \u00b1  0.0   B\/op g.a.r.n false   1    5    160.0 \u00b1  0.0    160.0 \u00b1  0.0    104.0 \u00b1  0.0   B\/op g.a.r.n false   1   10    184.0 \u00b1  0.0    184.0 \u00b1  0.0    112.0 \u00b1  0.0   B\/op g.a.r.n false   1  100    640.0 \u00b1  0.0    640.0 \u00b1  0.0    288.0 \u00b1  0.0   B\/op g.a.r.n false   5    1    184.0 \u00b1  0.0    184.0 \u00b1  0.0    104.0 \u00b1  0.0   B\/op g.a.r.n false   5    5    280.0 \u00b1  0.0    280.0 \u00b1  0.0    144.0 \u00b1  0.0   B\/op g.a.r.n false   5   10    400.0 \u00b1  0.0    400.0 \u00b1  0.0    192.0 \u00b1  0.0   B\/op g.a.r.n false   5  100   2664.1 \u00b1  0.0   2664.1 \u00b1  0.0   1088.0 \u00b1  0.0   B\/op g.a.r.n false  10    1    320.0 \u00b1  0.0    320.0 \u00b1  0.0    192.0 \u00b1  0.0   B\/op g.a.r.n false  10    5    520.0 \u00b1  0.0    520.0 \u00b1  0.0    272.0 \u00b1  0.0   B\/op g.a.r.n false  10   10    760.0 \u00b1  0.0    760.0 \u00b1  0.0    368.0 \u00b1  0.0   B\/op g.a.r.n false  10  100   5264.2 \u00b1  0.0   5264.2 \u00b1  0.0   2168.1 \u00b1  0.0   B\/op g.a.r.n false 100    1   2208.2 \u00b1  0.0   2168.2 \u00b1  0.0   1317.7 \u00b1  5.7   B\/op g.a.r.n false 100    5   4196.3 \u00b1  6.2   4168.3 \u00b1  0.0   2123.4 \u00b1  7.6   B\/op g.a.r.n false 100   10   6704.6 \u00b1  0.0   6664.5 \u00b1  0.0   3123.4 \u00b1  7.6   B\/op g.a.r.n false 100  100  51698.1 \u00b1  5.4  51666.3 \u00b1  0.0  21124.3 \u00b1  7.6   B\/op<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445! \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a <a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8148937\" rel=\"nofollow\">JDK-8148937<\/a> \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e, \u0447\u0442\u043e <a href=\"http:\/\/cr.openjdk.java.net\/~shade\/8148937\/notes.txt\" rel=\"nofollow\">\u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/a> (\u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f) \u0431\u044b\u043b\u0430 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u0430 <a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8149758\" rel=\"nofollow\">JDK-8149758<\/a>. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e <a href=\"https:\/\/mail.openjdk.java.net\/pipermail\/core-libs-dev\/2020-February\/064866.html\" rel=\"nofollow\">\u043f\u0438\u0441\u044c\u043c\u043e<\/a>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0430 JDK-8148937. \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, 1,5-2 -\u043a\u0440\u0430\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u0433\u043e \u0441\u0442\u043e\u044f\u0442.<\/p>\n<p>  <\/p>\n<h4 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e. \u0412\u043e\u0442 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0432\u043e\u0437\u044c\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 (\u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e) \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0434\u0443. \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u2014 \u0438 \u0442\u0443\u0442 \u0436\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0448\u044c\u0441\u044f \u0441\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0432\u0435\u0449\u0430\u043c\u0438. \u041d\u0443\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434, \u043d\u043e \u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0447\u0443\u0436\u043e\u0439, \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0443, \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/li>\n<li>\u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0437\u0430\u043b\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432 JDK \u0432\u044b\u0447\u0438\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u0435\u0441\u043f\u043e\u0449\u0430\u0434\u043d\u043e\u0439. \u041d\u0430\u0448\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0430\u043c \u0441\u0430\u043c\u044b\u043c\u0438 \u0432\u0435\u0440\u043d\u044b\u043c\u0438, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0438\u043b\u043b\u044e\u0437\u0438\u044f. \u041d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0439\u0442\u0435 \u043a\u0440\u0438\u0442\u0438\u043a\u0443, \u0434\u0430\u0436\u0435 \u0438 \u0440\u0430\u0437\u0433\u0440\u043e\u043c\u043d\u0443\u044e, \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u0441\u0435\u0440\u0434\u0446\u0443<\/li>\n<li>\u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043a\u0440\u0443\u0442\u044b\u0435 \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u044b \u043d\u0435 \u043e\u0431\u0435\u0449\u0430\u044e\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/433174\">\u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439<\/a> \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438 \u043d\u0430 100% \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430 \u0443\u0431\u0440\u0430\u043d\u044b \u043f\u043e\u0434 \u0441\u0443\u043a\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u043c\u0430\u043b\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432<\/li>\n<\/ul>\n<p>  <\/p>\n<h4 id=\"vmesto-poslesloviya\">\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u044f<\/h4>\n<p>  <\/p>\n<p>\u0423\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0432\u0435\u0441\u043d\u0430, \u0436\u0435\u043b\u0430\u044e \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u0442\u0435\u043f\u043b\u043e\u043c \u043e\u0449\u0443\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u0438\u0432 \u0441\u0438\u043b \u0438 \u0441\u043c\u0435\u043b\u043e \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0443\u043c\u0435\u0442\u044c \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0438 \u0441\u043d\u043e\u0432\u0430 \u0443\u0447\u0438\u0442\u044c\u0441\u044f \ud83d\ude42<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/488874\/\"> https:\/\/habr.com\/ru\/post\/488874\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488874\/\">\n<p><em>\u0410 \u044f \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u043b, \u044f \u043f\u0440\u043e\u043f\u0430\u0442\u0447\u0438\u043b SJ<br \/>  \u041e\u043f\u044f\u0442\u044c, \u043e\u043f\u044f\u0442\u044c, \u043e\u043f\u044f\u0442\u044c\u2026<br \/>  \u041e\u0445, \u043a\u0430\u043a \u043d\u0430\u043c\u0430\u044f\u043b\u0441\u044f \u044f \u0441 \u0442\u043e\u0431\u043e\u0439<br \/>  \u041c\u043e\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u043e\u043c\u0435\u0440 \u043f\u044f\u0442\u044c.<br \/>  <\/em><br \/>  \u041a\u0440\u0443\u0442\u0438\u043b\u043e\u0441\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e <del>\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439<\/del> \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0436\u0430\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 <code>StringJoiner<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u0445, \u0432\u0441\u0442\u0430\u0432\u0448\u0438\u0445 \u043d\u0430 \u043c\u043e\u0451\u043c \u043f\u0443\u0442\u0438. \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0441\u0447\u043b\u0435\u043d\u0451\u043d\u043a\u0430 \u0438 \u043a\u0438\u0448\u043a\u0438, \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u043e\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u0434\u0435\u0442\u0435\u0439 \u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u0438\u0446.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299072","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299072"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299072\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}