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:
@@ -11,15 +11,15 @@ type GSM7Coder struct{}
|
||||
// Otherwise Encode will allocate memory as it sees fit
|
||||
// Which is fine but not optimal
|
||||
// Preallocate the buffer with the size of EncodesInto bytes
|
||||
func (c *GSM7Coder) Encode(s string, buf *bytes.Buffer) error {
|
||||
func (c *GSM7Coder) Encode(s *string, buf *bytes.Buffer) error {
|
||||
// utf8 := *(*[]byte)(unsafe.Pointer(&s))
|
||||
utf8 := []byte(s)
|
||||
utf8 := []byte(*s)
|
||||
var (
|
||||
offset int = 1
|
||||
bitshift byte = 0
|
||||
leap, shift bool
|
||||
)
|
||||
encodedSize := GSM7EncodesInto(&s)
|
||||
encodedSize := GSM7EncodesInto(s)
|
||||
cap := buf.Cap()
|
||||
if cap < encodedSize {
|
||||
buf.Grow(encodedSize - cap)
|
||||
|
||||
Reference in New Issue
Block a user