New Upstream Release - golang-github-emersion-go-textwrapper
Ready changes
Summary
Merged new upstream version: 0.0~git20200911.65d8968 (was: 0.0~git20160606.d0e65e5).
Resulting package
Built on 2022-10-15T23:04 (took 3m33s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases golang-github-emersion-go-textwrapper-dev
Lintian Result
- golang-github-emersion-go-textwrapper-dev_0.0~git20200911.65d8968-1~jan+nur2_all.deb
- golang-github-emersion-go-textwrapper_0.0~git20200911.65d8968-1~jan+nur2.dsc
- golang-github-emersion-go-textwrapper_0.0~git20200911.65d8968-1~jan+nur2_amd64.buildinfo
- golang-github-emersion-go-textwrapper_0.0~git20200911.65d8968-1~jan+nur2_amd64.changes
Diff
diff --git a/debian/changelog b/debian/changelog
index 0edf739..28d32a0 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> Sat, 15 Oct 2022 23:01:28 -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)
+ }
+ }
+}
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files