hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit a9bcd38181ceb79afba82adcd4de1aebf571e74c
parent ef0f1a726901d6c614040cfc2d7e8f9a2ca97816
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Mon, 17 May 2021 19:39:40 +0200

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

As in: Do not retain the input slice.

Diffstat:
Mpublisher/htmlElementsCollector.go | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git 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() {