2 ms·
> Having StringBuilder be a private field on the parser instance is not an issue either - it is simply reused. It doesn’t matter for this API, but it is a code
by Someone 3y ago
> Having StringBuilder be a private field on the parser instance is not an issue either - it is simply reused.
It doesn’t matter for this API, but it is a code smell. It makes the class not reentrant.
Talking of the API, I would make it simpler to use and more idiomatic by making the entire public API
static IEnumerable<List<String>> parse(StreamReader sr)
That call would store the parser state (currently just the StreamReader and that reused StringBuilder) in a private inner class. There would not be a constructor of the publicly visible class, removing that code smell.