From ac7d5dba631a4e290307ddcf615c741cded1eefc Mon Sep 17 00:00:00 2001 From: Pavel Petrukhin Date: Wed, 10 Jun 2020 12:49:20 +0300 Subject: [PATCH] rfr(package): rename stringBuffer to stringBuilder --- common.go | 4 ++-- convert.go | 14 +++++++------- format.go | 10 +++++----- manipulate.go | 4 ++-- stringbuilder.go | 2 +- stringbuilder_go110.go | 2 +- translate.go | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common.go b/common.go index c16ae0f..f427cc8 100644 --- a/common.go +++ b/common.go @@ -6,8 +6,8 @@ package xstrings const bufferMaxInitGrowSize = 2048 // Lazy initialize a buffer. -func allocBuffer(orig, cur string) *bufferString { - output := &bufferString{} +func allocBuffer(orig, cur string) *stringBuilder { + output := &stringBuilder{} maxSize := len(orig) * 4 // Avoid to reserve too much memory at once. diff --git a/convert.go b/convert.go index bc5a03c..3d5a349 100644 --- a/convert.go +++ b/convert.go @@ -22,7 +22,7 @@ func ToCamelCase(str string) string { return "" } - buf := &bufferString{} + buf := &stringBuilder{} var r0, r1 rune var size int @@ -111,7 +111,7 @@ func camelCaseToLowerCase(str string, connector rune) string { return "" } - buf := &bufferString{} + buf := &stringBuilder{} wt, word, remaining := nextWord(str) for len(remaining) > 0 { @@ -373,7 +373,7 @@ func nextValidRune(str string, prev rune) (r rune, size int) { return } -func toLower(buf *bufferString, wt wordType, str string, connector rune) { +func toLower(buf *stringBuilder, wt wordType, str string, connector rune) { buf.Grow(buf.Len() + len(str)) if wt != upperCaseWord && wt != connectorWord { @@ -400,7 +400,7 @@ func SwapCase(str string) string { var r rune var size int - buf := &bufferString{} + buf := &stringBuilder{} for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) @@ -434,7 +434,7 @@ func FirstRuneToUpper(str string) string { return str } - buf := &bufferString{} + buf := &stringBuilder{} buf.WriteRune(unicode.ToUpper(r)) buf.WriteString(str[size:]) return buf.String() @@ -452,7 +452,7 @@ func FirstRuneToLower(str string) string { return str } - buf := &bufferString{} + buf := &stringBuilder{} buf.WriteRune(unicode.ToLower(r)) buf.WriteString(str[size:]) return buf.String() @@ -565,7 +565,7 @@ func Successor(str string) string { // Needs to add one character for carry. if i < 0 && carry != ' ' { - buf := &bufferString{} + buf := &stringBuilder{} buf.Grow(l + 4) // Reserve enough space for write. if lastAlphanumeric != 0 { diff --git a/format.go b/format.go index b197912..8cd76c5 100644 --- a/format.go +++ b/format.go @@ -27,7 +27,7 @@ func ExpandTabs(str string, tabSize int) string { var r rune var i, size, column, expand int - var output *bufferString + var output *stringBuilder orig := str @@ -87,7 +87,7 @@ func LeftJustify(str string, length int, pad string) string { remains := length - l padLen := Len(pad) - output := &bufferString{} + output := &stringBuilder{} output.Grow(len(str) + (remains/padLen+1)*len(pad)) output.WriteString(str) writePadString(output, pad, padLen, remains) @@ -113,7 +113,7 @@ func RightJustify(str string, length int, pad string) string { remains := length - l padLen := Len(pad) - output := &bufferString{} + output := &stringBuilder{} output.Grow(len(str) + (remains/padLen+1)*len(pad)) writePadString(output, pad, padLen, remains) output.WriteString(str) @@ -139,7 +139,7 @@ func Center(str string, length int, pad string) string { remains := length - l padLen := Len(pad) - output := &bufferString{} + output := &stringBuilder{} output.Grow(len(str) + (remains/padLen+1)*len(pad)) writePadString(output, pad, padLen, remains/2) output.WriteString(str) @@ -147,7 +147,7 @@ func Center(str string, length int, pad string) string { return output.String() } -func writePadString(output *bufferString, pad string, padLen, remains int) { +func writePadString(output *stringBuilder, pad string, padLen, remains int) { var r rune var size int diff --git a/manipulate.go b/manipulate.go index f232fb7..64075f9 100644 --- a/manipulate.go +++ b/manipulate.go @@ -130,7 +130,7 @@ func Insert(dst, src string, index int) string { // Scrub scrubs invalid utf8 bytes with repl string. // Adjacent invalid bytes are replaced only once. func Scrub(str, repl string) string { - var buf *bufferString + var buf *stringBuilder var r rune var size, pos int var hasError bool @@ -143,7 +143,7 @@ func Scrub(str, repl string) string { if r == utf8.RuneError { if !hasError { if buf == nil { - buf = &bufferString{} + buf = &stringBuilder{} } buf.WriteString(origin[:pos]) diff --git a/stringbuilder.go b/stringbuilder.go index 14b9bf7..bb0919d 100644 --- a/stringbuilder.go +++ b/stringbuilder.go @@ -4,4 +4,4 @@ package xstrings import "strings" -type bufferString = strings.Builder +type stringBuilder = strings.Builder diff --git a/stringbuilder_go110.go b/stringbuilder_go110.go index 4b4c380..dac389d 100644 --- a/stringbuilder_go110.go +++ b/stringbuilder_go110.go @@ -4,6 +4,6 @@ package xstrings import "bytes" -type bufferString struct { +type stringBuilder struct { bytes.Buffer } diff --git a/translate.go b/translate.go index 7ad8755..4210037 100644 --- a/translate.go +++ b/translate.go @@ -302,7 +302,7 @@ func (tr *Translator) Translate(str string) string { orig := str - var output *bufferString + var output *stringBuilder for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) @@ -499,7 +499,7 @@ func Squeeze(str, pattern string) string { var size int var skipSqueeze, matched bool var tr *Translator - var output *bufferString + var output *stringBuilder orig := str last = -1