Currently when dealing with fragmented messages we end up constructing an NmeaLineParser twice for each fragment. We do it once in the loop where we calculate the total size of the message and then again when we come to combine the individual payloads.
This does more work than necessary. A lightweight method that just reports the length of the payload without doing everything else that the NmeaLineParser constructor does would make this more efficient. (Since we'd be skipping the full validation in this initial step, it would need to do a basic sense check: it should check that the reported payload isn't longer than the whole message. But since we do eventually run the NmeaLineParser for each fragment, that should be enough.)
This is probably going to be of marginal value because the overwhelming majority of messages are not fragmented, but it's not nothing.
Currently when dealing with fragmented messages we end up constructing an
NmeaLineParsertwice for each fragment. We do it once in the loop where we calculate the total size of the message and then again when we come to combine the individual payloads.This does more work than necessary. A lightweight method that just reports the length of the payload without doing everything else that the
NmeaLineParserconstructor does would make this more efficient. (Since we'd be skipping the full validation in this initial step, it would need to do a basic sense check: it should check that the reported payload isn't longer than the whole message. But since we do eventually run theNmeaLineParserfor each fragment, that should be enough.)This is probably going to be of marginal value because the overwhelming majority of messages are not fragmented, but it's not nothing.