Просмотр исходного кода

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
tags/7.4.2
Fabian Lange 9 лет назад
Родитель
Сommit
c3fb52c0b1
1 измененных файлов: 4 добавлений и 13 удалений
  1. 4
    13
      client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java

+ 4
- 13
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) {

Загрузка…
Отмена
Сохранить