stevedlawrence commented on a change in pull request #419:
URL: https://github.com/apache/incubator-daffodil/pull/419#discussion_r488078655
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala
##########
@@ -203,31 +201,27 @@ abstract class SequenceParserBase(
pstate.mpstate.moveOverOneGroupIndexOnly()
}
- val newLastChildNode = pstate.infoset.contents.lastOption
- if (newLastChildNode != savedLastChildNode) {
- // We have added at least one child to to this complex during
+ val newLastChildNode = pstate.infoset.maybeLastChild
+ if (newLastChildNode.isDefined) {
+ // We have potentially added a child to to this complex during
// this array loop.
//
// If the new child is a DIArray, we know this DIArray has at
// least one element, but we don't know if we actually added a
// new one in this loop or not. So just get the last array
- // element and set it as final anyways. Note that we need a null
- // check because if we didn't add an array element this go
- // around, the last element may have already been walked and
- // freed and so could now be null.
+ // element and set it as final anyways.
//
// If it's not a DIArray, that means it's just an optional
// simple/complex and that will get set final below where all
// other non-array elements get set as final.
- newLastChildNode.get match {
- case a: DIArray => {
- val lastArrayElem = a.contents.last
- if (lastArrayElem != null) {
- lastArrayElem.setFinal()
- pstate.walker.walk()
- }
+ val lastChild = newLastChildNode.get
+ if (!lastChild.isSimple && !lastChild.isComplex) {
Review comment:
Yeah, I'm surprised to. Of all the changes, I think this one didn't make
a huge difference, it was definitely withing the margin of error for Java. But
it did seem to consistent error on the positive side of that difference so I
figured I'd keep it in to try to eek out every bit of performance. I'll add an
isArray so this is at least more readable.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]