Open 3052 opened 9 months ago
Sounds ok to me...
text/scanner.Scanner
or bufio.scanner
? I've not written a line of go code for 3 years 😅 , but the bufio
variant is maybe more suitable?
bufio can work, and actually might be the better option, since text/scanner is typically used against Go source code. however we would probably need to define a custom split:
https://godocs.io/bufio#Scanner.Split
also if you haven't written any Go code in years, it might be better to simply archive this repo, or transfer ownership to me. I code Go daily, both professional and personal.
I like this package because it has no third party imports:
https://github.com/jamesnetherton/m3u/blob/45aea2b60bc42cd569432224a6b9a97cdbf8c05f/go.mod#L1-L3
but I noticed today the parsing is based on regular expression:
https://github.com/jamesnetherton/m3u/blob/45aea2b60bc42cd569432224a6b9a97cdbf8c05f/m3u.go#L74
using this file:
I get this result:
so the RegExp option is using 4 times the memory, while the scanner option is double to triple the speed. its possible other options are better as well, the above implementation is just what I came up with.