publisher: Get the collector in line with the io.Writer interface

As in: Do not retain the input slice.
This commit is contained in:
Bjørn Erik Pedersen 2021-05-17 19:39:40 +02:00
parent ef0f1a7269
commit a9bcd38181
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -152,18 +152,21 @@ type htmlElementsCollectorWriter struct {
}
// Write collects HTML elements from p.
func (w *htmlElementsCollectorWriter) Write(p []byte) (n int, err error) {
n = len(p)
func (w *htmlElementsCollectorWriter) Write(p []byte) (int, error) {
w.input = p
w.pos = 0
for {
w.r = w.next()
if w.r == eof {
return
break
}
w.state = w.state(w)
}
w.pos = 0
w.input = nil
return len(p), nil
}
func (l *htmlElementsCollectorWriter) backup() {