jdk/src/share/classes/java/util/stream/ReferencePipeline.java
changeset 19800 6e1fef53ea55
parent 19799 efa9ff09b024
child 19850 93b368e54c1c
equal deleted inserted replaced
19799:efa9ff09b024 19800:6e1fef53ea55
   262                         downstream.begin(-1);
   262                         downstream.begin(-1);
   263                     }
   263                     }
   264 
   264 
   265                     @Override
   265                     @Override
   266                     public void accept(P_OUT u) {
   266                     public void accept(P_OUT u) {
   267                         // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   267                         try (Stream<? extends R> result = mapper.apply(u)) {
   268                         Stream<? extends R> result = mapper.apply(u);
   268                             // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   269                         if (result != null)
   269                             if (result != null)
   270                             result.sequential().forEach(downstream);
   270                                 result.sequential().forEach(downstream);
       
   271                         }
   271                     }
   272                     }
   272                 };
   273                 };
   273             }
   274             }
   274         };
   275         };
   275     }
   276     }
   289                         downstream.begin(-1);
   290                         downstream.begin(-1);
   290                     }
   291                     }
   291 
   292 
   292                     @Override
   293                     @Override
   293                     public void accept(P_OUT u) {
   294                     public void accept(P_OUT u) {
   294                         // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   295                         try (IntStream result = mapper.apply(u)) {
   295                         IntStream result = mapper.apply(u);
   296                             // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   296                         if (result != null)
   297                             if (result != null)
   297                             result.sequential().forEach(downstreamAsInt);
   298                                 result.sequential().forEach(downstreamAsInt);
       
   299                         }
   298                     }
   300                     }
   299                 };
   301                 };
   300             }
   302             }
   301         };
   303         };
   302     }
   304     }
   316                         downstream.begin(-1);
   318                         downstream.begin(-1);
   317                     }
   319                     }
   318 
   320 
   319                     @Override
   321                     @Override
   320                     public void accept(P_OUT u) {
   322                     public void accept(P_OUT u) {
   321                         // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   323                         try (DoubleStream result = mapper.apply(u)) {
   322                         DoubleStream result = mapper.apply(u);
   324                             // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   323                         if (result != null)
   325                             if (result != null)
   324                             result.sequential().forEach(downstreamAsDouble);
   326                                 result.sequential().forEach(downstreamAsDouble);
       
   327                         }
   325                     }
   328                     }
   326                 };
   329                 };
   327             }
   330             }
   328         };
   331         };
   329     }
   332     }
   343                         downstream.begin(-1);
   346                         downstream.begin(-1);
   344                     }
   347                     }
   345 
   348 
   346                     @Override
   349                     @Override
   347                     public void accept(P_OUT u) {
   350                     public void accept(P_OUT u) {
   348                         // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   351                         try (LongStream result = mapper.apply(u)) {
   349                         LongStream result = mapper.apply(u);
   352                             // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
   350                         if (result != null)
   353                             if (result != null)
   351                             result.sequential().forEach(downstreamAsLong);
   354                                 result.sequential().forEach(downstreamAsLong);
       
   355                         }
   352                     }
   356                     }
   353                 };
   357                 };
   354             }
   358             }
   355         };
   359         };
   356     }
   360     }