Remove NormalizedNodePruner.SimpleStack 98/81298/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Mar 2019 22:51:57 +0000 (23:51 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 29 Mar 2019 01:37:06 +0000 (02:37 +0100)
commit311a36931443f0753e73e72bb187788807a6e3de
treeece8bec326c037871271bc2764ab6b49d0679afe
parent38675700718aed7c5c5622750eea201a079db489
Remove NormalizedNodePruner.SimpleStack

This custom implementation is highly inefficient, because:
1) peek/pop operations perform get(int) and remove(int) operations
   on ArrayList, which are highly inefficient O(N)
2) it allocates an object for each entry

Replace this class with a stock Deque, which takes care of the first
problem, as push/pop/peek are amortized O(1).

For implementation use an ArrayDeque, which takes care of the second
problem, as stack entries are reused.

Change-Id: Ie59e2fb47f841e4e5fc08c3ab7e164ad0cb368ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8e3fb7b97f23fe0aba388b295fbe45d67d21e91c)
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java