final Integer[] levels = levelList.getLevelsDescendingArray();
final LevelStorageBackend[] levelData = new LevelStorageBackend[levels.length];
final int expressionsCount = levelList.size();
final int capacity = Math.min(20, expressionsCount);
final IntList activeExpressions = new IntList(capacity);
final IntList functions = new IntList(capacity);
final IntList pageEventListeners = new IntList(capacity);
for (int i = 0; i < levels.length; i++)
{
final int currentLevel = levels[i].intValue();
final Integer[] data = (Integer[])
levelList.getElementArrayForLevel(currentLevel, EMPTY_INTEGERARRAY);
for (int x = 0; x < data.length; x++)
{
final Integer position = data[x];
final Expression ex = expressions[position.intValue()];
final int globalPosition = position.intValue();
if (ex instanceof Function == false)
{
if (ex.getName() != null)
{
activeExpressions.add(globalPosition);
}
continue;
}
activeExpressions.add(globalPosition);
functions.add(globalPosition);
if (ex instanceof PageEventListener)
{
pageEventListeners.add(globalPosition);
}
}
levelData[i] = new LevelStorageBackend(currentLevel,
activeExpressions.toArray(),
functions.toArray(), pageEventListeners.toArray());
activeExpressions.clear();
functions.clear();
pageEventListeners.clear();
}
return levelData;
}