From: Bjørn Erik Pedersen Date: Mon, 17 May 2021 17:39:40 +0000 (+0200) Subject: publisher: Get the collector in line with the io.Writer interface X-Git-Tag: v0.84.0~41 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a9bcd38181ceb79afba82adcd4de1aebf571e74c;p=brevno-suite%2Fhugo publisher: Get the collector in line with the io.Writer interface As in: Do not retain the input slice. --- diff --git a/publisher/htmlElementsCollector.go b/publisher/htmlElementsCollector.go index 1bc1a09b..e1c743ea 100644 --- a/publisher/htmlElementsCollector.go +++ b/publisher/htmlElementsCollector.go @@ -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() {