Description
Every parser action copies a lot of state objects right now. These data structures could be redesigned so that most actions copy minimally. This is still in keeping with the functional-programming style of I/O where input operations don't modify an I/O layer, rather they produce values and a new State.
Currently the backend parsers consume and produce a PState. This object has many slots so copying it isn't cheap. One of the slots is an InStream object, also has to be copied, and depending on some things, a DFDLReader, may be there too.
All of these should be squished together into one class (called PState), which has a tree-like shape. The basic PState object should have two slots: bitPosition, and "Everything Else" so that just advancing the position causes minimal work.
Also suspect: the stacks of array pos, child pos and group pos should go away and become Dynamic Variables. (This may apply to other things as well).
The new PState should support the union of the operations of DFDLCharReader and InStream, plus should support getStringInBytes and getStringInCharacters methods so that primitives don't have to do their own charset decoding.