mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
use strings.Builder instead of bytes.Buffer where applicable
This commit is contained in:
parent
425cdffe39
commit
00e2c2816b
@ -6,7 +6,6 @@
|
||||
package irc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -447,7 +446,7 @@ func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
|
||||
|
||||
maxNamLen := 480 - len(client.server.name) - len(client.Nick())
|
||||
var namesLines []string
|
||||
var buffer bytes.Buffer
|
||||
var buffer strings.Builder
|
||||
if isJoined || !channel.flags.HasMode(modes.Secret) || isOper {
|
||||
for _, target := range channel.Members() {
|
||||
var nick string
|
||||
|
@ -4,14 +4,14 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"regexp/syntax"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// yet another glob implementation in Go
|
||||
|
||||
func addRegexp(buf *bytes.Buffer, glob string, submatch bool) (err error) {
|
||||
func addRegexp(buf *strings.Builder, glob string, submatch bool) (err error) {
|
||||
for _, r := range glob {
|
||||
switch r {
|
||||
case '*':
|
||||
@ -36,7 +36,7 @@ func addRegexp(buf *bytes.Buffer, glob string, submatch bool) (err error) {
|
||||
}
|
||||
|
||||
func CompileGlob(glob string, submatch bool) (result *regexp.Regexp, err error) {
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
buf.WriteByte('^')
|
||||
err = addRegexp(&buf, glob, submatch)
|
||||
if err != nil {
|
||||
@ -50,7 +50,7 @@ func CompileGlob(glob string, submatch bool) (result *regexp.Regexp, err error)
|
||||
// This is used for channel ban/invite/exception lists. It's applicable to k-lines
|
||||
// but we're not using it there yet.
|
||||
func CompileMasks(masks []string) (result *regexp.Regexp, err error) {
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
buf.WriteString("^(")
|
||||
for i, mask := range masks {
|
||||
err = addRegexp(&buf, mask, false)
|
||||
|
@ -4,7 +4,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -98,7 +97,7 @@ func (sm *SplitMessage) Is512() bool {
|
||||
type TokenLineBuilder struct {
|
||||
lineLen int
|
||||
delim string
|
||||
buf bytes.Buffer
|
||||
buf strings.Builder
|
||||
result []string
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user