stevedlawrence commented on a change in pull request #55: Fixes the issue of
separated empty optional elements, (ie. 1:2::4:5).
URL: https://github.com/apache/incubator-daffodil/pull/55#discussion_r175466501
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/ElementKindParsers.scala
##########
@@ -119,18 +119,26 @@ class DynamicEscapeSchemeParser(escapeScheme:
EscapeSchemeParseEv,
}
}
-class SequenceCombinatorParser(rd: TermRuntimeData, bodyParser: Parser)
+class SequenceCombinatorParser(rd: TermRuntimeData, childParsers: Seq[Parser])
extends CombinatorParser(rd) {
override def nom = "Sequence"
override lazy val runtimeDependencies = Nil
- override lazy val childProcessors = Seq(bodyParser)
+ override lazy val childProcessors = childParsers
+
+ val numChildParsers = childParsers.size
def parse(start: PState): Unit = {
+ var i: Int = 0
+
start.mpstate.groupIndexStack.push(1L) // one-based indexing
- bodyParser.parse1(start)
+ while (i < numChildParsers) {
+ val parser = childParsers(i)
Review comment:
childParsers is a Seq, which is implemented in Scala as a LinkedList, which
does not have constant time access to random elements. So this loop is
essentially O(N<superscript>2</superscript>). Instead of a Seq, we want this to
be something with constant time access like an Array, or we want to use things
like .head() and .tail() to iterate through the list. An Array will probably be
more efficient since I think tail() does alot of work behind the scenes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services