webrtc-sdp icon indicating copy to clipboard operation
webrtc-sdp copied to clipboard

Replace split_whitespace().collect() calls

Open nils-ohlmeier opened this issue 7 years ago • 2 comments

Instead of using split_whitespace().collect() to get a temporary vector just use split_whitespace() and then the iterator with .next() for parsing.

nils-ohlmeier avatar May 28 '17 04:05 nils-ohlmeier

The code currently checks the length of the result of the collect(). AFAIK there is no way of doing that with an Iter without consuming the Iter.

na-g avatar Jun 13 '19 05:06 na-g

Correct. But in hindsight I think these length checks are somewhat stupid. They make testing a lot harder then it needs to be. For some of the attributed the amount of tokens depends on one of the tokens. And when you consume the tokens from an Iter the parser can provide a precise error message what is wrong with line instead of just "it's too short". So basically I think we should not check the length at all and instead consume from the .next() calls.

nils-ohlmeier avatar Jun 14 '19 05:06 nils-ohlmeier