RFR: 8273684: Unnecessary Stack usage
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Mon Sep 13 19:29:26 UTC 2021
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
More information about the serviceability-dev
mailing list