RFR: 8273684: Unnecessary Stack usage
Bernd Eckenfels
ecki at zusammenkunft.net
Tue Sep 14 00:31:27 UTC 2021
Maybe better use addFirst(), for example in CommandProcessor there is a comment that order matters (did not check it more closely), so it’s probably best to not reverse orders in any place? The Dequeue Javadoc lists addFirst as the aproperiate stack#push replacement.
Gruss
Bernd
--
http://bernd.eckenfels.net
________________________________
Von: serviceability-dev <serviceability-dev-retn at openjdk.java.net> im Auftrag von Andrey Turbanov <github.com+741251+turbanoff at openjdk.java.net>
Gesendet: Monday, September 13, 2021 9:29:26 PM
An: client-libs-dev at openjdk.java.net <client-libs-dev at openjdk.java.net>; serviceability-dev at openjdk.java.net <serviceability-dev at openjdk.java.net>
Betreff: Re: RFR: 8273684: Unnecessary Stack usage
On Sun, 29 Aug 2021 21:14:19 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> Usage of thread-safe collection Stack is unnecessary. It's recommended to use ArrayDequeue if a thread-safe implementation is not needed.
Yeah. You are right! TIL that order of iteration is different in ArrayDequeu vs Stack: Stack.push() adds to the "end of stack" (it just calls Vector.add()), while ArrayDeque.push adds "first element"
Luckily for us there was only one place which depend on this. It's small method `javax.swing.text.html.HTMLDocument.HTMLReader#getPathTo`. I've changed method to use ArrayList instead.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5294
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20210914/8639de58/attachment.htm>
More information about the serviceability-dev
mailing list