{"id":290575,"date":"2018-10-10T12:05:03","date_gmt":"2018-10-10T08:05:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=290575"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=290575","title":{"rendered":"\u0417\u0430\u0433\u0443\u0431\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u042d\u0442\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043c\u043e\u0435\u0433\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0430 &#171;\u041a\u0430\u043a \u0437\u0430\u0433\u0443\u0431\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430&#187; \u0441 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 JPoint 2018. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0438 \u0441\u043b\u0430\u0439\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"http:\/\/2018.jpoint.ru\/talks\/1smez2ivjmiw0wskqimew0\/\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438<\/a>. \u0412 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u043b\u0430\u0434 \u043e\u0442\u043c\u0435\u0447\u0435\u043d \u043e\u0431\u0438\u0434\u043d\u044b\u043c \u0441\u0442\u0430\u043a\u0430\u043d\u0447\u0438\u043a\u043e\u043c \u0441\u043c\u0443\u0437\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043c\u0435\u0442 \u0434\u043e\u043a\u043b\u0430\u0434\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0430\u043a \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432 \u043d\u0451\u043c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430<\/li>\n<li>\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/li>\n<li>\u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0433\u0440\u0430\u0431\u043b\u0438<\/li>\n<li>\u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0431\u043b\u0435\u0439<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043a\u0443\u043b\u0443\u0430\u0440\u0430\u0445 \u043c\u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\/\u0443\u043f\u0443\u0449\u0435\u043d\u0438\u044f \u0432 \u0434\u043e\u043a\u043b\u0430\u0434\u0435, \u043e\u043d\u0438 \u0437\u0434\u0435\u0441\u044c \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b. \u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"vliyanie-poryadka-ispolneniya-na-proizvoditelnost\">\u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class User {   String name;   int age; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b <code>equals<\/code> \u0438 <code>hashCode<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">import lombok.EqualsAndHashCode;  @EqualsAndHashCode class User {   String name;   int age; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d, \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439? \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043e\u0431 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Object::equals<\/code>: \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043b\u0438\u0448\u044c \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0432\u043d\u044b, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043a\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043b\u044f <code>@EqualsAndHashCode<\/code> \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public boolean equals(Object that) {   \/\/...   if (name == null &amp;&amp; that.name != null) {     return false;   }   if (name != null &amp;&amp; !name.equals(that.name)) {     return false;   }   return age == that.age; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u043b\u0435\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0438\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0432\u0435\u0434\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>equals<\/code> &#171;\u0442\u044f\u0436\u0435\u043b\u0435\u0435&#187; \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>equals\/hashCode<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &#171;\u0418\u0434\u0435\u0438&#187;:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public boolean equals(Object o) {   if (this == o) {     return true;   }   if (o == null || getClass() != o.getClass()) {     return false;   }   User that = (User) o;   return age == that.age &amp;&amp; Objects.equals(name, that.name); }<\/code><\/pre>\n<p>  <\/p>\n<p>&#171;\u0418\u0434\u0435\u044f&#187; \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u043c\u044b \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c <code>@EqualsAndHashCode<\/code> \u0438 \u0431\u0443\u0434\u0435\u043c \u044f\u0432\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c <code>equals\/hashCode<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class User {   List&lt;T&gt; props;   String name;   int age; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c <code>equals\/hashCode<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public boolean equals(Object o) {   if (this == o) {     return true;   }   if (o == null || getClass() != o.getClass()) {     return false;   }   User that = (User) o;   return age == that.age       &amp;&amp; Objects.equals(props, that.props)   \/\/ &lt;----       &amp;&amp; Objects.equals(name, that.name); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0447\u0442\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0435. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442, \u0432\u0435\u0434\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0430\u0432\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u0432\u043e (\u0442. \u0435. \u0432\u0440\u0435\u043c\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0442\u0451\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0434\u043b\u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438):<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0434\u0435\u0441\u044c \u0431\u044b\u043b\u0430 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041c\u0435\u0442\u043e\u0434 <code>java.lang.String::equals<\/code> <a href=\"http:\/\/hg.openjdk.java.net\/jdk8\/jdk8\/hotspot\/file\/87ee5ee27509\/src\/share\/vm\/classfile\/vmSymbols.hpp#l763\">\u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/java.lang.String public boolean equals(Object anObject) {   if (this == anObject) {     return true;   }   if (anObject instanceof String) {     String anotherString = (String) anObject;     int n = value.length;     if (n == anotherString.value.length) {       char v1[] = value;       char v2[] = anotherString.value;       int i = 0;       while (n-- != 0) {     \/\/ &lt;----         if (v1[i] != v2[i])           return false;         i++;       }       return true;     }   }   return false; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 <code>ArrayList<\/code>-\u043e\u0432 (\u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430). \u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 <code>ArrayList<\/code> \u0441 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c, \u0447\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>equals<\/code> \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d4\/hn\/yg\/d4hnyguezlpyxz3pgunk22ha1cm.png\"><\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/AbstractList::equals  public boolean equals(Object o) {   if (o == this) {     return true;   }   if (!(o instanceof List)) {     return false;   }    ListIterator&lt;E&gt; e1 = listIterator();   ListIterator&lt;?&gt; e2 = ((List&lt;?&gt;) o).listIterator();   while (e1.hasNext() &amp;&amp; e2.hasNext()) {    \/\/ &lt;----     E o1 = e1.next();     Object o2 = e2.next();     if (!(o1 == null ? o2 == null : o1.equals(o2))) {       return false;     }   }   return !(e1.hasNext() || e2.hasNext()); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043f\u043e\u043f\u0430\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043d\u0438\u043c. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0435\u0441\u0442\u044c \u0434\u0432\u0430 <code>ArrayList<\/code>-\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u043e\u0434\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 99<\/li>\n<li>\u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 100<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0434\u0432\u0443\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043f\u0440\u0438 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 <code>AbstractSet<\/code>), \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f 99 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0438 \u043b\u0438\u0448\u044c \u043d\u0430 \u0441\u043e\u0442\u043e\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u043f\u0438\u0441\u043a\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h4 id=\"chyo-tam-u-kotlinovcev\">\u0427\u0451 \u0442\u0430\u043c \u0443 \u043a\u043e\u0442\u043b\u0438\u043d\u043e\u0432\u0446\u0435\u0432?<\/h4>\n<p>  <\/p>\n<pre><code>data class User(val name: String, val age: Int);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u043a\u0430\u043a \u0443 \u043b\u043e\u043c\u0431\u043e\u043a\u0430 \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public boolean equals(Object o) {   if (this == o) {     return true;   }   if (o instanceof User) {     User u = (User) o;     if (Intrinsics.areEqual(name, u.name) &amp;&amp; age == u.age) {  \/\/ &lt;----       return true;     }   }   return false; }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435? &#8212; \u0416\u0430\u043b\u043e\u0432\u0430\u0442\u044c\u0441\u044f!<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>IDEA-170178 Comparison of collections should be executed at the very end of IDEA-generated equals()<br \/>  <a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-170178\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-170178<\/a><\/p>\n<p>  <\/p>\n<p>Reordering of comparison in @EqualsAndHashCode for better performance #1543<br \/>  <a href=\"https:\/\/github.com\/rzwitserloot\/lombok\/issues\/1543\">https:\/\/github.com\/rzwitserloot\/lombok\/issues\/1543<\/a><\/p>\n<p>  <\/p>\n<p>KT-23184 Auto-generated equals() of data class is not optimal<br \/>  <a href=\"https:\/\/youtrack.jetbrains.com\/issue\/KT-23184\">https:\/\/youtrack.jetbrains.com\/issue\/KT-23184<\/a><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<h4 id=\"uslozhnim-zadachu\">\u0423\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">void check(Dto dto) {   SomeEntity entity = jpaRepository.findOne(dto.getId());   boolean valid = dto.isValid();    if (valid &amp;&amp; entity.hasGoodRating()) { \/\/ &lt;----     \/\/do smth   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 \u0434\u0430\u0436\u0435 \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0438\u0442\u043e\u0433 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u0435\u043b\u043a\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>valid<\/code> \u043b\u043e\u0436\u043d\u043e, \u0442\u043e \u043a\u043e\u0434 \u0432 \u0431\u043b\u043e\u043a\u0435 <code>if<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void check(Dto dto) {   boolean valid = dto.isValid();   if (valid &amp;&amp; hasGoodRating(dto)) {     \/\/do smth   } }  \/\/ \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0435, \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432\u043a\u0443\u0441\u0430 boolean hasGoodRating(Dto dto) {   SomeEntity entity = jpaRepository.findOne(dto.getId());   return entity.hasGoodRating(); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u0438\u0437 \u043a\u0443\u043b\u0443\u0430\u0440\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0438\u0437 <code>JpaRepository::findOne<\/code> \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u044d\u0448\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u2014 \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">boolean checkChild(Dto dto) {   Long id = dto.getId();   Entity entity = jpaRepository.findOne(id);   return dto.isValid() &amp;&amp; entity.hasChild(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">boolean checkChild(Dto dto) {   if (!dto.isValid()) {     return false;   }   return jpaRepository.findOne(dto.getId()).hasChild(); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043d\u0435 \u043f\u043e\u043f\u0430\u0432\u0448\u0435\u0435 \u0432 \u0434\u043e\u043a\u043b\u0430\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043d\u0435\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Entity class ParentEntity {   @ManyToOne(fetch = LAZY)   @JoinColumn(name = \"CHILD_ID\")   private ChildEntity child;    @Enumerated(EnumType.String)   private SomeType type;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a &#171;\u043b\u0435\u043d\u0438\u0432\u044b\u043c&#187; \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\/\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043f\u043e\u043b\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0434\u0438\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u043e\u0431\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443, \u043d\u043e \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439\/\u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"cikly-i-massovaya-obrabotka\">\u0426\u0438\u043a\u043b\u044b \u0438 \u043c\u0430\u0441\u0441\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043e\u0441\u043e\u0431\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u0445 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Transactional void enrollStudents(Set&lt;Long&gt; ids) {   for (Long id : ids) {     Student student = jpaRepository.findOne(id); \/\/ &lt;---- O(n)     enroll(student);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437-\u0437\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <code>enrollStudents<\/code> \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438: \u0442\u043e\u0433\u0434\u0430 <strong>\u043a\u0430\u0436\u0434\u044b\u0439<\/strong> \u0432\u044b\u0437\u043e\u0432 <code>o.s.d.j.r.JpaRepository::findOne<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0432 \u043d\u043e\u0432\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 (\u0441\u043c. <a href=\"https:\/\/github.com\/spring-projects\/spring-data-jpa\/blob\/64062aa559f2a48871c6244dbf6bfe8620d92306\/src\/main\/java\/org\/springframework\/data\/jpa\/repository\/support\/SimpleJpaRepository.java#L74\">SimpleJpaRepository<\/a>), \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0441\u0431\u0440\u043e\u0441 \u043a\u044d\u0448\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Transactional void enrollStudents(Set&lt;Long&gt; ids) {   if (ids.isEmpty()) {     return;   }   for (Student student : jpaRepository.findAll(ids)) {     enroll(student);   } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0437\u043c\u0435\u0440\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0432 \u043c\u043a\u0441) \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 (10 \u0438 100 \u0448\u0442\u0443\u043a)<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p2\/0b\/zq\/p20bzq2tlnp3-mj8zlx8c96411e.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/911de0a7adeb1559192214e92a0e351ebae2dd0c\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/collection\/LoopVsSingleCallBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Oracle \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 1000 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432 <code>findAll<\/code>, \u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>ORA-01795: maximum number of expressions in a list is 1000<\/code>.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u044f\u0436\u0435\u043b\u043e\u0433\u043e (\u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u044e\u0447\u0435\u0439) <code>in<\/code>-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0445\u0443\u0436\u0435, \u0447\u0435\u043c n \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0422\u0443\u0442 \u0432\u0441\u0451 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0445\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 \u0446\u0438\u043a\u043b\u0430 \u043d\u0430 \u043c\u0430\u0441\u0441\u043e\u0432\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0436\u0435\u0442 \u0443\u0445\u0443\u0434\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h4 id=\"bolee-slozhnyy-primer-na-tu-zhe-temu\">\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0442\u0443 \u0436\u0435 \u0442\u0435\u043c\u0443<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">for (Long id : ids) {   Region region = jpaRepository.findOne(id);   if (region == null) {        \/\/ &lt;---- \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0435     region = new Region();     region.setId(id);   }   use(region); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0438\u043a\u043b \u043d\u0430 <code>JpaRepository::findAll<\/code>, \u0442. \u043a. \u044d\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443: \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 <code>JpaRepository::findAll<\/code> \u0431\u0443\u0434\u0443\u0442 \u043d\u0435 <code>null<\/code> \u0438 \u0431\u043b\u043e\u043a <code>if<\/code> \u043d\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0442\u043e \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0411\u0414<br \/>  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u0438\u0431\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043b\u0438\u0431\u043e \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435. \u0422. \u0435. \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0411\u0414 \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u042f\u0432\u0430 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u2014 <code>HashMap<\/code> \u2014 \u043f\u043e\u0432\u0435\u0440\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0411\u0414:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Map&lt;Long, Region&gt; regionMap = jpaRepository.findAll(ids)   .stream()   .collect(Collectors.toMap(Region::getId, Function.identity()));  for (Long id : ids) {   Region region = map.get(id);   if (region == null) {     region = new Region();     region.setId(id);   }   use(region); }<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"primer-v-obratnuyu-storonu\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ class Saver @Transactional(propagation = Propagation.REQUIRES_NEW) public void save(List&lt;AuditEntity&gt; entities) {   jpaRepository.save(entities); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u043e\u0432\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 @Transactional public void audit(List&lt;AuditDto&gt; inserts) {   inserts.map(this::toEntities).forEach(saver::save);  \/\/ &lt;---- }  \/\/ class Saver  @Transactional(propagation = Propagation.REQUIRES_NEW) \/\/ &lt;---- public void save(List&lt;AuditEntity&gt; entities) {   jpaRepository.save(entities); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Saver::save<\/code> \u0441\u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Transactional public void audit(List&lt;AuditDto&gt; inserts) {   List&lt;AuditEntity&gt; bulk = inserts     .map(this::toEntities)     .flatMap(List::stream)  \/\/ &lt;----     .collect(toList());   saver.save(bulk); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0441\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043e\u0449\u0443\u0442\u0438\u043c\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 (\u0432\u0440\u0435\u043c\u044f \u0432 \u043c\u043a\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/f7\/3r\/n9\/f73rn9gtjw7fdgiqrfwkq7tfme4.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/911de0a7adeb1559192214e92a0e351ebae2dd0c\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/audit\/AuditBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0436\u0435\u0448\u044c \u043e \u0432\u044b\u0437\u043e\u0432\u0435 <code>JpaRepository::findOne<\/code> \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043c \u043c\u0435\u0440\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-165730\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-165730<\/a><br \/>  IDEA-165730 Warn about inefficient usage of JpaRepository<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-165942\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-165942<\/a><br \/>  <del>IDEA-165942<\/del> Inspection to replace method call in a loop with bulk operation<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2017.1<\/strong><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0411\u0414, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0422\u0430\u0433\u0438\u0440 <a href=\"https:\/\/habr.com\/users\/lany\/\" class=\"user_link\">lany<\/a> \u0412\u0430\u043b\u0435\u0435\u0432 \u043f\u043e\u0448\u0435\u043b \u0434\u0430\u043b\u044c\u0448\u0435. \u0418 \u0435\u0441\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;Long&gt; list = new ArrayList&lt;&gt;(); for (Long id : items) {   list.add(id); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c &#171;\u0418\u0434\u0435\u044f&#187; \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;Long&gt; list = new ArrayList&lt;&gt;(); list.addAll(items);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0434\u0430\u0436\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0435\u0451 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430, \u0432\u0435\u0434\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0449\u0451 \u043a\u043e\u0440\u043e\u0447\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;Long&gt; list = new ArrayList&lt;&gt;(items);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c (\u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0441)<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u043b\u044f ArrayList-\u0430 \u044d\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u0451\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gi\/6j\/o8\/gi6jo8xwigpdckqz6jtuw4cmane.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f HashSet-\u0430 \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u0440\u0430\u0434\u0443\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/u9\/lo\/fy\/u9lofyf2wy2hffk8gd0uwvrmmke.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/bulk\/BulkOperationBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-138456\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-138456<\/a><br \/>  <del>IDEA-138456<\/del> New inspection: Collection.addAll() replaceable with parametrized constructor<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 142.1217<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-178761\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-178761<\/a><br \/>  <del>IDEA-178761<\/del> Inspection &#8216;Collection.addAll() replaceable with parametrized constructor&#8217; should be turned on by default<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2017.3<\/strong><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h4 id=\"udalenie-iz-arraylist-a\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 <code>ArrayList<\/code>-\u0430<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">for (int i = from; i &lt; to; i++) {   list.remove(from); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>List::remove<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public E remove(int index) {   Objects.checkIndex(index, size);   modCount++;   E oldValue = elementData(index);   int numMoved = size - index - 1;   if (numMoved &gt; 0) {     System.arraycopy(array, index + 1, array, index, numMoved); \/\/ &lt;----   }   array[--size] = null; \/\/ clear to let GC do its work   return oldValue; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">list.subList(from, to).clear();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f?<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">for (int i = from; i &lt; to; i++) {   E removed = list.remove(from);   use(removed); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043e\u0447\u0438\u0449\u0430\u0435\u043c\u043e\u043c\u0443 \u043f\u043e\u0434\u0441\u043f\u0438\u0441\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;String&gt; removed = list.subList(from, to); removed.forEach(this::use); removed.clear();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432 \u0446\u0438\u043a\u043b\u0435, \u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043c\u0435\u043d\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443. \u0421\u043c\u044b\u0441\u043b \u0435\u0433\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0432\u0438\u0433\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u044f\u0447\u0435\u0439\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/\u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u0442. \u043a. \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u043e\u0433\u043e for (int i = from; i &lt; to; i++) {   E removed = list.remove(from);   use(removed, i); }  \/\/\u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0442. \u043a. \u0441\u0434\u0432\u0438\u0433 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 for (int i = to - 1; i &gt;= from; i--) {   E removed = list.remove(i);   use(removed, reverseIndex(i)); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0432\u0441\u0435 \u0442\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 (\u043f\u043e\u0434 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d % \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 100):<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Java 8<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/4h\/ii\/tq\/4hiitqg5a7d3bk6lxi8od422yky.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Java 9<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ow\/mo\/ty\/owmotysgwdqquagklf1yhlrquz0.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e?<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0423\u0437\u0440\u0435\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xm\/ni\/s9\/xmnis9jllk8rozgh8xacdneyhd8.png\"><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u0441 \u043a\u043e\u043d\u0446\u0430, \u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0441\u0434\u0432\u0438\u0433\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ ArrayList public E remove(int index) {   rangeCheck(index);    modCount++;   E oldValue = elementData(index);    int numMoved = size - index - 1;   if (numMoved &gt; 0) {  \/\/ &lt;---- \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f     System.arraycopy(elementData, index+1, elementData, index, numMoved);   }   elementData[--size] = null; \/\/ clear to let GC do its work    return oldValue; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/911de0a7adeb1559192214e92a0e351ebae2dd0c\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/bulk\/remove\/RemoveFromArrayListBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-177466\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-177466<\/a><br \/>  <del>IDEA-177466<\/del> Detect List.remove(index) called in a loop<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2018.2<\/strong><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<h2 id=\"oblast-vidimosti-i-proizvoditelnost\">\u041e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u043e\u0441\u043e\u0431\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u0445 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void leaveForTheSecondYear() {   List&lt;Student&gt; naughty = repository.findNaughty();   List&lt;Student&gt; underAchieving = repository.findUnderAchieving(); \/\/ &lt;----    if (settings.leaveBothCategories()) {     leaveForTheSecondYear(naughty, underAchieving); \/\/ &lt;----     return;   }   leaveForTheSecondYear(naughty); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0443\u0436\u0430\u0435\u043c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043c\u0438\u043d\u0443\u0441 1 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void leaveForTheSecondYear() {   List&lt;Student&gt; naughty = repository.findNaughty();    if (Settings.leaveBothCategories()) {       List&lt;Student&gt; underAchieving = repository.findUnderAchieving(); \/\/ &lt;----     leaveForTheSecondYear(naughty, underAchieving); \/\/ &lt;----     return;   }   leaveForTheSecondYear(naughty); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c: \u0430 \u043a\u0430\u043a \u0436\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437? \u041f\u043e\u0447\u0435\u043c\u0443 &#171;\u0418\u0434\u0435\u044f&#187; \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0430 \u043e \u043b\u0435\u0436\u0430\u0449\u0435\u043c \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438?<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b: \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 (\u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441 \u0411\u0414) \u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043e\u0431\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u0445, \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445, \u0441\u043a\u0430\u0436\u0435\u043c, \u0432\u043d\u0443\u0442\u0440\u044c \u0431\u043b\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u0440\u0437\u0430\u0446\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043d\u043e, \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e, \u0442. \u043a. \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@org.jetbrains.annotations.Contract(pure = true)<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"http:\/\/mvnrepository.com\/artifact\/org.jetbrains\/annotations\">jetbrains-annotations<\/a> \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ com.intellij.util.ArrayUtil @Contract(pure = true) public static int find(@NotNull int[] src, int obj) {   return indexOf(src, obj); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u043d\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<h2 id=\"samyy-neobychnyy-primer\">\u0421\u0430\u043c\u044b\u0439 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>  <\/p>\n<pre><code class=\"java\">@Service public class RemoteService {   private ContractCounter contractCounter;    @Transactional(readOnly = true)   \/\/ &lt;----   public int countContracts(Dto dto) {     if (dto.isInvalid()) {       return -1;   \/\/ &lt;----     }     return contractCounter.countContracts(dto);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0434\u0430\u0436\u0435 \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 (\u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 -1 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430).<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043c\u0435\u0442\u043e\u0434\u0430 <code>ContractCounter::countContracts<\/code>, \u0433\u0434\u0435 \u043e\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430, \u0430 \u0438\u0437 &#171;\u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e&#187; \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0451 \u0443\u0431\u0440\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f -1 (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8k\/uu\/lp\/8kuulppcl4vli1c5ir-txozcemi.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0431\u0430\u0439\u0442):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xp\/du\/ke\/xpdukewr4nnooj2vtaktok4ngnm.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/transaction\/LazyTransactionBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u0441\u043c\u043e\u0442\u0440\u044f\u0449\u0438\u0435 &#171;\u043d\u0430\u0440\u0443\u0436\u0443&#187; \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u043e\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u0438 (\u044d\u0442\u043e \u043d\u0435 \u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c) \u0438 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0411\u0414 \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"preobrazovanie-datyvremeni-v-stroku\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443<\/h2>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0432\u0435\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u2014 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443. \u0414\u043e &#171;\u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u0438&#187; \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">SimpleDateFormat formatter = new SimpleDateFormat(\"dd.MM.yyyy\"); String dateAsStr = formatter.format(date);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u0432\u044b\u0445\u043e\u0434\u043e\u043c JDK 8 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <code>LocalDate\/LocalDateTime<\/code> \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <code>DateTimeFormatter<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"java\">DateTimeFormatter formatter = ofPattern(\"dd.MM.yyyy\"); String dateAsStr = formatter.format(localDate);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437\u043c\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Date date = new Date(); LocalDate localDate = LocalDate.now(); SimpleDateFormat sdf = new SimpleDateFormat(\"dd.MM.yyyy\"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern(\"dd.MM.yyyy\");  @Benchmark public String simpleDateFormat() {   return sdf.format(date); }  @Benchmark public String dateTimeFormatter() {   return dtf.format(localDate); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0440\u0435\u043c\u044f (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zq\/jq\/sx\/zqjqsxjevqpmuckdddvu4gysaoa.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0430\u043c\u044f\u0442\u044c (\u0431\u0430\u0439\u0442):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9j\/yq\/sw\/9jyqswjtyiwq3i8fkutenvyuj7g.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043d\u0435 \u0438 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <code>java.util.Date<\/code>. \u0411\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043d\u0430\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c <code>Date<\/code> \u0432 <code>LocalDate<\/code>, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0443? \u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Benchmark public String measureDateConverted(Data data) {   LocalDate localDate = toLocalDate(data.date);   return data.dateTimeFormatter.format(localDate); }  private LocalDate toLocalDate(Date date) {   return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0440\u0435\u043c\u044f (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/j5\/ob\/mf\/j5obmfec_kvfivo46wat9rmf8e8.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0430\u043c\u044f\u0442\u044c (\u0431\u0430\u0439\u0442):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hx\/hm\/on\/hxhmon8ss12qyv9s4is6byoy164.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>Date<\/code> -&gt; <code>LocalDate<\/code> \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 &#171;\u0434\u0435\u0432\u044f\u0442\u043a\u0438&#187;. \u041d\u0430 &#171;\u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u0435&#187; \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0436\u0440\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e <code>DateTimeFormatter<\/code>-a.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/formatter\/FormatterBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"eschyo-vosmyorka\">\u0415\u0449\u0451 &#171;\u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u0430&#187;<\/h2>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u0438\u0434\u0438\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Iterator&lt;Long&gt; iterator = items \/\/ ArrayList&lt;Integer&gt;   .stream()   .map(Long::valueOf)   .collect(toList())  \/\/ &lt;---- \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a?   .iterator();  while (iterator.hasNext()) {   bh.consume(iterator.next()); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0431\u0435\u0440\u0451\u043c \u0435\u0451:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Iterator&lt;Long&gt; iterator = items \/\/ ArrayList&lt;Integer&gt;   .stream()   .map(Long::valueOf)   .iterator();  while (iterator.hasNext()) {   bh.consume(iterator.next()); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/un\/mp\/pf\/unmppfr6sd8ybi3k7r7jrdsdfty.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0441 \u0434\u0435\u0432\u044f\u0442\u043a\u043e\u0439:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hc\/rb\/p9\/hcrbp98qezjcm5fegv27cywcadu.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0412\u044b\u0448\u0435 \u044f \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u043b, \u0447\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0432\u043e\u0442 \u043c\u044b \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043b\u0438\u0448\u043d\u0435\u0435 \u2014 \u0438 (\u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e) \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0445\u0443\u0436\u0435. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c, \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0434\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u0438\u0445 \u043f\u043e\u0434 \u043b\u0443\u043f\u043e\u0439:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u043a\u0440\u044b\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">Iterator iterator1 = items.stream().collect(toList()).iterator(); Iterator iterator2 = items.stream().iterator();<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rn\/ah\/kf\/rnahkfz2qdyuw0k_cjeorqawqki.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>ArrayList$Itr<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043d\u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public boolean hasNext() {   return cursor != size; }  public E next() {   checkForComodification();   int i = cursor;   if (i &gt;= size) {     throw new NoSuchElementException();   }   Object[] elementData = ArrayList.this.elementData;   if (i &gt;= elementData.length) {     throw new ConcurrentModificationException();   }   cursor = i + 1;   return (E) elementData[lastRet = i]; }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ug\/yb\/pi\/ugybpiiwmjj5-fbcazvmfdjd2tq.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0435\u0435, \u044d\u0442\u043e <code>Spliterators$Adapter<\/code>, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u2014 <code>ArrayList$ArrayListSpliterator<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043d\u0435\u043c\u0443 \u0441\u043b\u043e\u0436\u043d\u0435\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">\/\/ java.util.Spliterators$Adapter  public boolean hasNext() {   if (!valueReady)     spliterator.tryAdvance(this);   return valueReady; }  public T next() {   if (!valueReady &amp;&amp; !hasNext())     throw new NoSuchElementException();   else {     valueReady = false;     return nextElement;   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pf\/5p\/gj\/pf5pgjkfhhfw__h8ie7m6oflxqq.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/jvm-profiling-tools\/async-profiler\">async-profiler<\/a>:<\/p>\n<p>  <\/p>\n<pre><code>15.64%  j.u.ArrayList$ArrayListSpliterator.tryAdvance 10.67%  j.u.s.SpinedBuffer.clear  9.86%  j.u.Spliterators$1Adapter.hasNext  8.81%  j.u.s.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer  6.01%  o.o.j.i.Blackhole.consume  5.71%  j.u.s.ReferencePipeline$3$1.accept  5.57%  j.u.s.SpinedBuffer.accept  5.06%  c.l.l.b.ir.IteratorFromStreamBenchmark.iteratorFromStream  4.80%  j.l.Long.valueOf  4.53%  c.l.l.b.i.IteratorFromStreamBenchmark$$Lambda$8.885721577.apply<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0443, \u0445\u043e\u0442\u044f \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u0441\u0447\u0451\u0442\u0443, \u043e\u043d \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0432\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">items   .stream()   .map(Long::valueOf)   .forEach(bh::consume);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rf\/is\/i0\/rfisi0vsfoezlcvtd43h2lhlvfi.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><code>Stream::forEach<\/code> \u044f\u0432\u043d\u043e \u0432 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435, \u0430 \u0432\u0435\u0434\u044c \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e: \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043b\u0435\u0436\u0438\u0442 <code>ArrayListSpliterator<\/code>, \u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0430\u0441\u044c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u044c:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>29.04%  o.o.j.i.Blackhole.consume 22.92%  j.u.ArrayList$ArrayListSpliterator.forEachRemaining 14.47%  j.u.s.ReferencePipeline$3$1.accept  8.79%  j.l.Long.valueOf  5.37%  c.l.l.b.i.IteratorFromStreamBenchmark$$Lambda$9.617691115.accept  4.84%  c.l.l.b.i.IteratorFromStreamBenchmark$$Lambda$8.1964917002.apply  4.43%  j.u.s.ForEachOps$ForEachOp$OfRef.accept  4.17%  j.u.s.Sink$ChainedReference.end  1.27%  j.l.Integer.longValue  0.53%  j.u.s.ReferencePipeline.map<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 &#171;\u043f\u0440\u043e\u0433\u043b\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f&#187; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <code>Blackhole<\/code>. \u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044f\u0432\u0430-\u043a\u043e\u0434\u0430. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0443\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0441 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">forEach:\u00b7gc.alloc.rate.norm                 100  avgt   30  216,001 \u00b1 0,002  B\/op iteratorFromStream:\u00b7gc.alloc.rate.norm      100  avgt   30  416,004 \u00b1 0,006  B\/op<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, <code>Stream::forEach<\/code> \u0434\u0430\u0451\u0442 \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0430\u043b\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0434\u043e &#171;\u0447\u0451\u0440\u043d\u043e\u0439 \u0434\u044b\u0440\u044b&#187; \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2f\/5w\/1y\/2f5w1ydxlo5oomf8bfmhbqtynze.png\"><\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0438\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u0440\u043e\u043f\u0430\u043b \u0432\u044b\u0437\u043e\u0432 <code>ArrayListSpliterator::tryAdvance<\/code>, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <code>ArrayListSpliterator::forEachRemaining<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/ ArrayListSpliterator public void forEachRemaining(Consumer&lt;? super E&gt; action) {   int i, hi, mc; \/\/ hoist accesses and checks from loop   ArrayList&lt;E&gt; lst; Object[] a;   if (action == null)     throw new NullPointerException();   if ((lst = list) != null &amp;&amp; (a = lst.elementData) != null) {     if ((hi = fence) &lt; 0) {       mc = lst.modCount;       hi = lst.size;     }     else       mc = expectedModCount;     if ((i = index) &gt;= 0 &amp;&amp; (index = hi) &lt;= a.length) {       for (; i &lt; hi; ++i) {         @SuppressWarnings(\"unchecked\") E e = (E) a[i];             \/\/ &lt;----         action.accept(e);       }       if (lst.modCount == mc)         return;     }   }   throw new ConcurrentModificationException(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c <code>ArrayListSpliterator::forEachRemaining<\/code> \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0437\u0430 1 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0445\u043e\u0434 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f \u0443\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432 <code>ArrayListSpliterator::tryAdvance<\/code>.<br \/>  <code>ArrayListSpliterator::forEachRemaining<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u0447\u0451\u0442\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 <\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Iterator&lt;Long&gt; iterator = items   .stream()   .map(Long::valueOf)   .collect(toList())   .iterator();  while (iterator.hasNext()) {   bh.consume(iterator.next()); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u043d\u0430 <\/p>\n<p>  <\/p>\n<pre><code class=\"java\">items   .stream()   .map(Long::valueOf)   .forEach(bh::consume);<\/code><\/pre>\n<p>  <\/p>\n<p>\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0432\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u0430, \u0442. \u043a. \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043a\u043e\u043f\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0441\u0430\u043c \u0441\u0442\u0440\u0438\u043c, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u0441\u0442\u0440\u0438\u043c\u0430.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/iterator\/IteratorFromStreamBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0438\u043c\u0435\u044f \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u044c\u0442\u0435 \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 &#171;\u0436\u0435\u043b\u0435\u0437\u043d\u044b\u0435&#187; \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u043b\u0438\u0448\u043d\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u0440\u0435\u0434\u0438\u0442) \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0443\u0449\u0438\u0439\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0430\u0451\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432 \u0432\u0438\u0434\u0435 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430.<\/p>\n<p>  <\/p>\n<h4 id=\"dva-podvoha\">\u0414\u0432\u0430 \u043f\u043e\u0434\u0432\u043e\u0445\u0430<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">StackTraceElement[] trace = th.getStackTrace(); StackTraceElement[] newTrace = Arrays   .asList(trace)   .subList(0, depth)   .toArray(new StackTraceElement[newDepth]);  \/\/ &lt;----<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u2014 \u043f\u0440\u043e\u0442\u0443\u0445\u0448\u0435\u0435 &#171;\u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435&#187;, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>Collection::toArray<\/code> \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. <a href=\"https:\/\/shipilev.net\/blog\/2016\/arrays-wisdom-ancients\/\">\u0417\u0434\u0435\u0441\u044c<\/a> \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0440\u0435\u0434\u0438\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430, \u0438 \u0434\u043b\u044f \u0435\u0451 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0440\u0435\u0432\u044c\u044e\u0435\u0440\u0430 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u043a\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0442 \u044d\u0442\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0438\u0448\u0435\u0442 \u0420\u043e\u0431\u0438\u043d \u041a\u043e\u043b\u043b\u0438\u043d\u0433\u0432\u0443\u0434:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043e\u043d [\u0438\u0441\u0442\u043e\u0440\u0438\u043a] \u0447\u0438\u0442\u0430\u0435\u0442 \u041a\u043e\u0434\u0435\u043a\u0441 \u0424\u0435\u043e\u0434\u043e\u0441\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c \u2013 \u044d\u0434\u0438\u043a\u0442 \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. <strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e\u0441\u0438\u043b\u044c\u043d\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0438\u0445 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/strong>. \u0427\u0442\u043e\u0431\u044b \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e, <strong>\u0438\u0441\u0442\u043e\u0440\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u043e\u0440<\/strong>&#8230;<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0437\u0430 \u0442\u0435\u043c <strong>\u0447\u0442\u043e<\/strong> \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<p>  <\/p>\n<p>1) \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432<br \/>  2) \u0447\u0430\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f<br \/>  3) \u043e\u0442\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u043c\u0435\u0440\u0435\u0432\u0430\u043b\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u044d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">StackTraceElement[] trace = th.getStackTrace(); StackTraceElement[] newTrace = Arrays.copyOf(trace, depth);     \/\/ \u043d\u0435\u044f\u0432\u043d\u044b\u0439 \u043e\u0442\u0441\u0447\u0451\u0442 \u0441 0 \/\/ \u0438\u043b\u0438 StackTraceElement[] newTrace = Arrays.copyOfRange(trace, 0, depth); \/\/\u044f\u0432\u043d\u044b\u0439 \u043e\u0442\u0441\u0447\u0451\u0442 \u0441 0<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xg\/ia\/-8\/xgia-8mdesgh-cpqm1cla0n8zz4.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/array\/SubListToArrayBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<h4 id=\"strimoz-golovnogo-mozga\">\u0421\u0442\u0440\u0438\u043c\u043e\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0437\u0433\u0430<\/h4>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;T&gt; list = getList(); Set&lt;T&gt; set = getSet(); return list.stream().allMatch(set::contains); \/\/ \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435?<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043d\u0430\u0431\u043e\u0440, \u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0432 \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">List&lt;T&gt; list = getList(); Set&lt;T&gt; set = getSet(); return set.containsAll(list);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3c\/tc\/pr\/3ctcprq3scexhaaifc9hiywbj98.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/911de0a7adeb1559192214e92a0e351ebae2dd0c\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/stream\/AllMatchVsContainsAllBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<h4 id=\"nenuzhnye-obyortki\">\u041d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u0451\u0440\u0442\u043a\u0438<\/h4>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">interface FileNameLoader {   String[] loadFileNames(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0439 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">private FileNameLoader loader;  void load() {   for (String str : asList(loader.loadFileNames())) {  \/\/ &lt;---- \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435     use(str);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442, \u0447\u0442\u043e \u0441\u0430\u0445\u0430\u0440\u043e\u043a <code>forEach<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438, \u0445\u043e\u0442\u044f \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">private FileNameLoader loader;  void load() {   for (String str : loader.loadFileNames()) {  \/\/ &lt;---- \u043f\u0440\u043e\u0449\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435      use(str);   } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0440\u0430\u0432\u043d\u0438\u043c (\u043d\u0441):<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pa\/kn\/hc\/paknhcvrp1cf7g-fw3cn4euxrse.png\"><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/blob\/master\/benchmark-runners\/src\/main\/java\/com\/luxoft\/logeek\/benchmark\/array\/ArrayVsAsListIterationBenchmark.java\">\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-182206\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-182206<\/a><br \/>  <del>IDEA-182206<\/del> Simplification for Arrays.asList().subList().toArray()<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2018.1<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-180847\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-180847<\/a><br \/>  <del>IDEA-180847<\/del> Inspection &#8216;Call to Collection.toArray with zero-length array argument&#8217; brings pessimization<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2018.1<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-181928\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-181928<\/a><br \/>  <del>IDEA-181928<\/del> Stream.allMatch(Collection::contains) can be simplified to Collection.containsAll()<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2018.1<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/IDEA-184240\">https:\/\/youtrack.jetbrains.com\/issue\/IDEA-184240<\/a><br \/>  <del>IDEA-184240<\/del> Unnecessary array-to-collection wrapping should be detected<br \/>  <strong>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 2018.1<\/strong><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434: \u0432 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a\u0436\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u043e\u0440\u043e\u0447\u0435<\/li>\n<li>\u043d\u0430\u0434\u0451\u0436\u043d\u0435\u0435<\/li>\n<li>\u043f\u0440\u043e\u0449\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u044b\u043b\u043e\u0432\u0438\u043b\u0438 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u043d\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0448\u0438\u043c \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0430\u043c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0435\u043c: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u044f\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438 \u043f\u0440\u043e\u043f\u044b\u043b\u0435\u0441\u043e\u0441\u044f\u0442 \u043a\u043e\u0434 \u0441\u0430\u043c\u043e\u0439 &#171;\u0418\u0434\u0435\u0438&#187; (\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u0443\u044e \u0438 \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438), \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0432\u043e\u0437\u044c\u043c\u0443\u0442 \u043d\u043e\u0432\u0443\u044e &#171;\u0418\u0434\u0435\u044e&#187; \u0438 \u043f\u043e\u0447\u0438\u0441\u0442\u044f\u0442 \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 (\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438), \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u044b \u0441\u0430\u043c\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437.<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0437\u0430\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438: <a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\">https:\/\/github.com\/stsypanov\/logeek-night-benchmark<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0430\u043f\u043a\u0430 \u0441 \u0437\u0430\u043c\u0435\u0440\u0430\u043c\u0438: <a href=\"https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/tree\/master\/results\">https:\/\/github.com\/stsypanov\/logeek-night-benchmark\/tree\/master\/results<\/a><\/p>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \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\/post\/423305\/\"> https:\/\/habr.com\/post\/423305\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u042d\u0442\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043c\u043e\u0435\u0433\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0430 &#171;\u041a\u0430\u043a \u0437\u0430\u0433\u0443\u0431\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430&#187; \u0441 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 JPoint 2018. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0438 \u0441\u043b\u0430\u0439\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"http:\/\/2018.jpoint.ru\/talks\/1smez2ivjmiw0wskqimew0\/\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438<\/a>. \u0412 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u043b\u0430\u0434 \u043e\u0442\u043c\u0435\u0447\u0435\u043d \u043e\u0431\u0438\u0434\u043d\u044b\u043c \u0441\u0442\u0430\u043a\u0430\u043d\u0447\u0438\u043a\u043e\u043c \u0441\u043c\u0443\u0437\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043c\u0435\u0442 \u0434\u043e\u043a\u043b\u0430\u0434\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0430\u043a \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432 \u043d\u0451\u043c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430<\/li>\n<li>\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/li>\n<li>\u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0433\u0440\u0430\u0431\u043b\u0438<\/li>\n<li>\u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0431\u043b\u0435\u0439<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043a\u0443\u043b\u0443\u0430\u0440\u0430\u0445 \u043c\u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\/\u0443\u043f\u0443\u0449\u0435\u043d\u0438\u044f \u0432 \u0434\u043e\u043a\u043b\u0430\u0434\u0435, \u043e\u043d\u0438 \u0437\u0434\u0435\u0441\u044c \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b. \u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/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-290575","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/290575","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=290575"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/290575\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=290575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=290575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=290575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}