You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by da...@apache.org on 2015/09/21 13:06:09 UTC

[3/3] wicket git commit: Improved the queued components lookup

Improved the queued components lookup

The queued components lookup back up the tree is now optimized such
that it only looks up until the queue region is found, and only
dequeues when there are components to dequeue.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2246156f
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2246156f
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2246156f

Branch: refs/heads/WICKET-5981
Commit: 2246156fc61abec16cd3f4f1be21dcd59be0aa16
Parents: 76cd226
Author: Martijn Dashorst <ma...@gmail.com>
Authored: Mon Sep 21 13:04:10 2015 +0200
Committer: Martijn Dashorst <ma...@gmail.com>
Committed: Mon Sep 21 13:04:10 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/MarkupContainer.java | 38 ++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/2246156f/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 8bbb1fa..d7da398 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1715,16 +1715,34 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
 		else
 		{
 			MarkupContainer containerWithQueue = this;
-			while (containerWithQueue.queue == null || containerWithQueue.queue.isEmpty())
+
+			// check if there are any parent containers that have queued components, up till our
+			// queue region
+			while (containerWithQueue.isQueueEmpty() &&
+				!(containerWithQueue instanceof IQueueRegion))
 			{
 				containerWithQueue = containerWithQueue.getParent();
 				if (containerWithQueue == null)
 				{
+					// no queued components are available for dequeuing, so we can stop
 					return;
 				}
 			}
 
-			MarkupContainer queueRegion = (MarkupContainer)findParent(IQueueRegion.class);
+			// when there are no components to be dequeued, just stop
+			if (containerWithQueue.isQueueEmpty())
+				return;
+
+			// get the queue region where we are going to dequeue components in
+			MarkupContainer queueRegion = containerWithQueue;
+
+			// the container with queued components could be a queue region, if not, find the region
+			// to dequeue in
+			if (!queueRegion.isQueueRegion())
+			{
+				queueRegion = (MarkupContainer)queueRegion.findParent(IQueueRegion.class);
+			}
+
 			if (queueRegion != null && !queueRegion.getRequestFlag(RFLAG_CONTAINER_DEQUEING))
 			{
 				queueRegion.dequeue();
@@ -1733,6 +1751,22 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
 	}
 
 	/**
+	 * @return {@code true} when one or more components are queued
+	 */
+	private boolean isQueueEmpty()
+	{
+		return queue == null || queue.isEmpty();
+	}
+
+	/**
+	 * @return {@code true} when this markup container is a queue region
+	 */
+	private boolean isQueueRegion() 
+	{
+		return IQueueRegion.class.isInstance(this);
+	}
+
+	/**
 	 * Run preliminary operations before running {@link #dequeue(DequeueContext)}. More in detail it
 	 * throws an exception if the container is already dequeuing, and it also takes care of setting
 	 * flag {@code RFLAG_CONTAINER_DEQUEING} to true before running {@link #dequeue(DequeueContext)}