olabusayoT commented on code in PR #1509:
URL: https://github.com/apache/daffodil/pull/1509#discussion_r2216345444
##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/PropProviders.scala:
##########
@@ -141,17 +141,24 @@ final class ChainPropProvider(leafProvidersArg:
Seq[LeafPropProvider], forAnnota
sources: Seq[LeafPropProvider],
pname: String
): PropertyLookupResult = {
- val allNotFound =
- for { source <- sources } yield {
- val res = source.leafFindProperty(pname)
- res match {
- case _: Found => return res // found it! return right now.
- case nf @ NotFound(_, _, _) => nf
- }
+ var result: Option[PropertyLookupResult] = None
+ val allNotFound = scala.collection.mutable.ListBuffer.empty[NotFound]
+
+ val iter = sources.iterator
+ while (iter.hasNext && result.isEmpty) {
+ val res = iter.next().leafFindProperty(pname)
+ res match {
+ case f: Found =>
+ result = Some(f)
+ case nf: NotFound =>
+ allNotFound += nf
Review Comment:
I couldn't get collectFirst to work. Our tests were failing, but I got a
map/find combo to work
val result: Option[PropertyLookupResult] = sources
.map { source =>
source.leafFindProperty(pname)
}
.find {
case _: Found => true
case nf: NotFound =>
allNotFound += nf
false
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]