Run of fresh-snapshots for golang-github-emersion-go-textwrapper

Try this locally (using the lintian-brush package):

debcheckout golang-github-emersion-go-textwrapper
cd golang-github-emersion-go-textwrapper
new-upstream --snapshot

Merge these changes:

Summary

Merged new upstream version: 0.0~git20200911.65d8968 (was: 0.0~git20160606.d0e65e5).

Diff

Branch: main

diff --git a/debian/changelog b/debian/changelog
index 0edf739..aeb5570 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
-golang-github-emersion-go-textwrapper (0.0~git20160606.d0e65e5-3) UNRELEASED; urgency=low
+golang-github-emersion-go-textwrapper (0.0~git20200911.65d8968-1) UNRELEASED; urgency=low
 
   * Set upstream metadata fields: Bug-Database, Bug-Submit.
+  * New upstream snapshot.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sun, 30 Aug 2020 12:38:44 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 03 Jun 2021 14:40:07 -0000
 
 golang-github-emersion-go-textwrapper (0.0~git20160606.d0e65e5-2) unstable; urgency=medium
 
diff --git a/wrapper.go b/wrapper.go
index 8a94380..43b26e7 100644
--- a/wrapper.go
+++ b/wrapper.go
@@ -6,11 +6,11 @@ import (
 )
 
 type writer struct {
-	Sep string
 	Len int
 
-	w io.Writer
-	i int
+	sepBytes []byte
+	w        io.Writer
+	i        int
 }
 
 func (w *writer) Write(b []byte) (N int, err error) {
@@ -25,7 +25,7 @@ func (w *writer) Write(b []byte) (N int, err error) {
 		N += n
 		b = b[to:]
 
-		_, err = w.w.Write([]byte(w.Sep))
+		_, err = w.w.Write(w.sepBytes)
 		if err != nil {
 			return
 		}
@@ -49,9 +49,9 @@ func (w *writer) Write(b []byte) (N int, err error) {
 // length and adds a separator between these parts.
 func New(w io.Writer, sep string, l int) io.Writer {
 	return &writer{
-		Sep: sep,
-		Len: l,
-		w: w,
+		Len:      l,
+		sepBytes: []byte(sep),
+		w:        w,
 	}
 }
 
diff --git a/wrapper_test.go b/wrapper_test.go
index 10ec944..6e1c5df 100644
--- a/wrapper_test.go
+++ b/wrapper_test.go
@@ -2,38 +2,39 @@ package textwrapper_test
 
 import (
 	"bytes"
+	"io/ioutil"
 	"testing"
 
 	"github.com/emersion/go-textwrapper"
 )
 
 func TestNew(t *testing.T) {
-	tests := []struct{
-		input []string
+	tests := []struct {
+		input    []string
 		expected string
 	}{
 		{
-			input: []string{"helloworldhelloworldhelloworld"},
+			input:    []string{"helloworldhelloworldhelloworld"},
 			expected: "hello/world/hello/world/hello/world",
 		},
 		{
-			input: []string{"helloworldhelloworldhe"},
+			input:    []string{"helloworldhelloworldhe"},
 			expected: "hello/world/hello/world/he",
 		},
 		{
-			input: []string{"helloworldhelloworldhe", "ll"},
+			input:    []string{"helloworldhelloworldhe", "ll"},
 			expected: "hello/world/hello/world/hell",
 		},
 		{
-			input: []string{"helloworldhelloworldhe", "llo"},
+			input:    []string{"helloworldhelloworldhe", "llo"},
 			expected: "hello/world/hello/world/hello",
 		},
 		{
-			input: []string{"helloworldhelloworldhe", "lloworld"},
+			input:    []string{"helloworldhelloworldhe", "lloworld"},
 			expected: "hello/world/hello/world/hello/world",
 		},
 		{
-			input: []string{"helloworldhelloworldhe", "llo", "wor", "ld"},
+			input:    []string{"helloworldhelloworldhe", "llo", "wor", "ld"},
 			expected: "hello/world/hello/world/hello/world",
 		},
 	}
@@ -52,3 +53,42 @@ func TestNew(t *testing.T) {
 		}
 	}
 }
+
+func BenchmarkWriteWith10K(b *testing.B) {
+	b.ReportAllocs()
+
+	input := make([]byte, 10000)
+	w := textwrapper.New(ioutil.Discard, "/", 3)
+	for i := 0; i < b.N; i++ {
+		_, err := w.Write(input)
+		if err != nil {
+			b.Error(err)
+		}
+	}
+}
+
+func BenchmarkWriteWith100K(b *testing.B) {
+	b.ReportAllocs()
+
+	input := make([]byte, 100000)
+	w := textwrapper.New(ioutil.Discard, "/", 3)
+	for i := 0; i < b.N; i++ {
+		_, err := w.Write(input)
+		if err != nil {
+			b.Error(err)
+		}
+	}
+}
+
+func BenchmarkWriteWith1M(b *testing.B) {
+	b.ReportAllocs()
+
+	input := make([]byte, 1000000)
+	w := textwrapper.New(ioutil.Discard, "/", 3)
+	for i := 0; i < b.N; i++ {
+		_, err := w.Write(input)
+		if err != nil {
+			b.Error(err)
+		}
+	}
+}

Branch: upstream

Tag: upstream/0.0_git20200911.65d8968

Diff is too long (more than 200 lines). Download the raw diff.

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-emersion-go-textwrapper-dev

Lintian Result

Full worker log Full build log Full dist log