sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [sling-org-apache-sling-query] 03/03: SLING-7540 AlternativeIterator improvement
Date Fri, 09 Mar 2018 19:30:37 GMT
This is an automated email from the ASF dual-hosted git repository.

jeb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-query.git

commit d54e6f67312eb59307b45ed53e06592c2b316b11
Author: JE Bailey <jeb@apache.org>
AuthorDate: Fri Mar 9 14:30:01 2018 -0500

    SLING-7540 AlternativeIterator improvement
    
    Returns once item has been identified.
---
 .../java/org/apache/sling/query/iterator/AlternativeIterator.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/query/iterator/AlternativeIterator.java b/src/main/java/org/apache/sling/query/iterator/AlternativeIterator.java
index 9b0a5bb..ce78b9a 100644
--- a/src/main/java/org/apache/sling/query/iterator/AlternativeIterator.java
+++ b/src/main/java/org/apache/sling/query/iterator/AlternativeIterator.java
@@ -34,15 +34,11 @@ public class AlternativeIterator<T> extends AbstractIterator<Option<T>>
{
 
 	@Override
 	protected Option<T> getElement() {
-		Option<T> element = null;
 		for (Iterator<Option<T>> i : iterators) {
 			if (i.hasNext()) {
-				Option<T> option = i.next();
-				if (element == null || !option.isEmpty()) {
-					element = option;
-				}
+				return i.next();
 			}
 		}
-		return element;
+		return null;
 	}
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
jeb@apache.org.

Mime
View raw message