aboutsummaryrefslogtreecommitdiffstats
path: root/skate/slugify.go
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-26 21:11:14 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-26 21:11:14 +0200
commita23c2cee4fe5bccabbf30392d670a380ef80b82b (patch)
tree57a9b08077069f0497d10b01ca29133ef3a9fbc0 /skate/slugify.go
parent63346653420a687c7b10bea0e0becf73996f6c5e (diff)
downloadrefcat-a23c2cee4fe5bccabbf30392d670a380ef80b82b.tar.gz
refcat-a23c2cee4fe5bccabbf30392d670a380ef80b82b.zip
switch to sligthly more performance string builder
Diffstat (limited to 'skate/slugify.go')
-rw-r--r--skate/slugify.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/skate/slugify.go b/skate/slugify.go
index e8fa8bf..5cdc838 100644
--- a/skate/slugify.go
+++ b/skate/slugify.go
@@ -1,18 +1,17 @@
package skate
import (
- "bytes"
"fmt"
"strings"
)
// slugifyString is a basic string slugifier.
func slugifyString(s string) string {
- var buf bytes.Buffer
+ var sb strings.Builder
for _, c := range strings.TrimSpace(strings.ToLower(s)) {
if (c > 96 && c < 123) || (c > 47 && c < 58) || (c == 32) || (c == 9) || (c == 10) {
- fmt.Fprintf(&buf, "%c", c)
+ fmt.Fprintf(&sb, "%c", c)
}
}
- return strings.Join(strings.Fields(buf.String()), " ")
+ return strings.Join(strings.Fields(sb.String()), " ")
}