diff options
author | Fabian Lange <lange.fabian@gmail.com> | 2015-03-02 13:28:15 +0100 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-03-11 08:20:14 +0000 |
commit | b2db17740aa8e7b33b208c73559c1d5d3461c192 (patch) | |
tree | 70aa48781c37391b33134f998d42d93c4457bfcf | |
parent | 155ffa7560e6445557ad2d04d2f83411c391debb (diff) | |
download | vaadin-framework-b2db17740aa8e7b33b208c73559c1d5d3461c192.tar.gz vaadin-framework-b2db17740aa8e7b33b208c73559c1d5d3461c192.zip |
Improve performance of getMeasureTargetsJsArray (#16973).
This change optimizes the method
LayoutDependenyTree.getMeasureTargetsJsArray.
The previous code dumps both MeasureQueues and then iterates over the
vertical one and then checks if it is present in the horizontal one.
If it is not present it pushes the element to the array (which usually
invokes an arraycopy in js).
The new code adds both Queues to a new FastStringSet which does deal
with duplicates nicely.
While this is not much faster than the dumps, it avoids the array
allocations and the separate iteration for duplicate checking.
Change-Id: I2f643a2d0b32e4c2517efff16c196387f38f0d8a
-rw-r--r-- | client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index da3aed4bbc..af261c0208 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -690,19 +690,10 @@ public class LayoutDependencyTree { } public JsArrayString getMeasureTargetsJsArray() { - FastStringSet horizontalQueue = getMeasureQueue(HORIZONTAL); - JsArrayString measureTargets = horizontalQueue.dump(); - - JsArrayString verticalDump = getMeasureQueue(VERTICAL).dump(); - int length = verticalDump.length(); - for (int i = 0; i < length; i++) { - String connectorId = verticalDump.get(i); - if (!horizontalQueue.contains(connectorId)) { - measureTargets.push(connectorId); - } - } - - return measureTargets; + FastStringSet allMeasuredTargets = FastStringSet.create(); + allMeasuredTargets.addAll(getMeasureQueue(HORIZONTAL)); + allMeasuredTargets.addAll(getMeasureQueue(VERTICAL)); + return allMeasuredTargets.dump(); } public void logDependencyStatus(ComponentConnector connector) { |