From dev-return-91076-apmail-ant-dev-archive=ant.apache.org@ant.apache.org Sun May 20 14:08:06 2018 Return-Path: X-Original-To: apmail-ant-dev-archive@www.apache.org Delivered-To: apmail-ant-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 97C9418BAF for ; Sun, 20 May 2018 14:08:06 +0000 (UTC) Received: (qmail 92789 invoked by uid 500); 20 May 2018 14:08:05 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 92715 invoked by uid 500); 20 May 2018 14:08:05 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 92704 invoked by uid 99); 20 May 2018 14:08:04 -0000 Received: from mail-relay.apache.org (HELO mailrelay2-lw-us.apache.org) (207.244.88.137) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 May 2018 14:08:04 +0000 Received: from v45346.1blu.de (v45346.1blu.de [178.254.23.72]) by mailrelay2-lw-us.apache.org (ASF Mail Server at mailrelay2-lw-us.apache.org) with ESMTPSA id F1D743CE for ; Sun, 20 May 2018 14:08:03 +0000 (UTC) Received: by v45346.1blu.de (Postfix, from userid 1000) id 5D56D40005F; Sun, 20 May 2018 16:08:02 +0200 (CEST) From: Stefan Bodewig To: dev@ant.apache.org Subject: Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration References: <5922e87b713f4180a85000a2e4150b76@git.apache.org> <1038617953.2265237.1526538866559@mail.yahoo.com> <4c09ca54-1511-ca0e-1e6f-aa253835ee98@apache.org> <878t8hc8zj.fsf@v45346.1blu.de> Date: Sun, 20 May 2018 16:08:02 +0200 In-Reply-To: (Gintautas Grigelionis's message of "Sun, 20 May 2018 11:46:33 +0200") Message-ID: <87zi0u4dz1.fsf@v45346.1blu.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain On 2018-05-20, Gintautas Grigelionis wrote: > 2018-05-18 16:51 GMT+02:00 Stefan Bodewig : >> On 2018-05-18, Gintautas Grigelionis wrote: >>> I believe that Streams API can at least implement the logic run by an >>> original Enumeration in a more concise way, or provide more powerful >> idioms. >>> That IMO makes it worth the while to investigate the Streams >> alternatives. >> I agree to do that as soon as we want to change the code to do something >> that wants to use said idioms. I don't really see a reason to change the >> code before that point in time. >>> In the process I also found out that other iterators could be used in a >>> more efficient way, or that there is a redundant object construction >> going >>> on. >>> If you wish, I may spend some time to describe the changes I introduced, >>> and maybe then we could discuss the their merits. >> Let's use the concrete example that raised Maarten's email. In >> ZipScanner we've gone from >> Enumeration e = zf.getEntries(); >> while (e.hasMoreElements()) { >> ZipEntry entry = e.nextElement(); >> to >> StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry >> -> { >> the Enumeration instance is created in both cases. What is the benfit >> for the ZipScanner class right now? > FWIW, the original java.util.ZipFile has a stream() that is based on an > iterator since Java 8 [1]. > What is the reason for adding that method if Enumeration is so much better? > ;-) > I dare say, the benefit is that streams are parallelizable. I'm afraid you misunderstood my question. I didn't ask why streams may be preferable over Enumerations when you write new code or change existing code. I was asking how does this benefit the existing code right now when there is no other change at all. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org