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