Refactor encoding to use *string instead of string as input
I don't want to clone the whole input string
This commit is contained in:
@@ -22,7 +22,7 @@ func TestGSM7EncodeSimpleASCIIString(t *testing.T) {
|
||||
input := short8nString
|
||||
|
||||
expected := short8nStringEncodedBytes
|
||||
err := coder.Encode(input, &buf)
|
||||
err := coder.Encode(&input, &buf)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got %v", err)
|
||||
@@ -39,7 +39,7 @@ func TestGSM7EncodeComplexASCIIString(t *testing.T) {
|
||||
input := longNot8nString
|
||||
|
||||
expected := longNot8nStringEncodedBytes
|
||||
err := coder.Encode(input, &buf)
|
||||
err := coder.Encode(&input, &buf)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got %v", err)
|
||||
@@ -56,7 +56,7 @@ func TestGSM7EncodeComplex8nASCIIString(t *testing.T) {
|
||||
input := "Ducks are fucking great, they quacks, O quackers, what the fuck."
|
||||
|
||||
expected := long8nStringEncodedBytes
|
||||
err := coder.Encode(input, &buf)
|
||||
err := coder.Encode(&input, &buf)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got %v", err)
|
||||
@@ -74,7 +74,7 @@ func TestGSM7EncodeDoesNotAllocateMoreThanNecessary(t *testing.T) {
|
||||
buf.Reset()
|
||||
|
||||
expected := buf.Cap()
|
||||
err := coder.Encode(input, buf)
|
||||
err := coder.Encode(&input, buf)
|
||||
actual := buf.Cap()
|
||||
|
||||
if err != nil {
|
||||
@@ -93,7 +93,7 @@ func TestGSM7EncodeDoesAllocateWhenNecessary(t *testing.T) {
|
||||
buf.Reset()
|
||||
|
||||
original := buf.Cap()
|
||||
err := coder.Encode(input, &buf)
|
||||
err := coder.Encode(&input, &buf)
|
||||
modified := buf.Cap()
|
||||
|
||||
if err != nil {
|
||||
@@ -111,7 +111,7 @@ func TestGSM7EncodeEmptyString(t *testing.T) {
|
||||
input := ""
|
||||
|
||||
expected := []byte{}
|
||||
err := coder.Encode(input, &buf)
|
||||
err := coder.Encode(&input, &buf)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got %v", err)
|
||||
@@ -330,7 +330,7 @@ func BenchmarkGSM7EncodeSimpleASCIIString(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
coder.Encode(input, &buf)
|
||||
coder.Encode(&input, &buf)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ func BenchmarkGSM7EncodeComplexASCIIString(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
coder.Encode(input, &buf)
|
||||
coder.Encode(&input, &buf)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func BenchmarkGSM7EncodeComplex8nASCIIString(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
coder.Encode(input, &buf)
|
||||
coder.Encode(&input, &buf)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,6 +364,6 @@ func BenchmarkGSM7EncodeComplex8nASCIIStringPrealloc(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := bytes.NewBuffer(make([]byte, GSM7EncodesInto(&input)))
|
||||
buf.Reset()
|
||||
coder.Encode(input, buf)
|
||||
coder.Encode(&input, buf)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user