mbeckerle commented on code in PR #1338:
URL: https://github.com/apache/daffodil/pull/1338#discussion_r1807082323


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/SpecifiedLengthParsers.scala:
##########
@@ -85,7 +85,9 @@ sealed abstract class SpecifiedLengthParserBase(eParser: 
Parser, erd: RuntimeDat
     if (pState.processorStatus ne Success) return
     val finalEndPos0b = startingBitPos0b + nBits
 
-    captureValueLength(pState, ULong(startingBitPos0b), ULong(dis.bitPos0b))
+    // if we haven't already set the value length, set it now
+    if (pState.infoset.valueLength.isEndUndef)
+      captureValueLength(pState, ULong(startingBitPos0b), ULong(dis.bitPos0b))

Review Comment:
   All the complexity around whether to insert a value-length capture parser at 
the start/end is about symmetry of the parser with the way the unparser works. 
   
   Capturing length when parsing is easy. Record start position when parser is 
entered, ending position when it is exited.  Probably so light weight that it's 
not worth trying to optimize it away.
   
   Unparsing... not so much. The unparser has to unwind and allow unparsing to 
continue while the value length is suspended. Definitely we want none of this 
overhead for elements which no expression references their length. We only want 
capture of length overheads when it is essential. I am also hoping that some of 
this is simpler for prefixed lengths, which don't work for unparsing with 
suspensions, etc. currently. 



-- 
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]

Reply via email to