diff --git a/server/client_resp.go b/server/client_resp.go index 30a8f87..cfcaf5d 100644 --- a/server/client_resp.go +++ b/server/client_resp.go @@ -12,7 +12,6 @@ import ( "net" "runtime" "strconv" - "strings" "time" ) @@ -124,7 +123,7 @@ func (c *respClient) handleRequest(reqData [][]byte) { c.cmd = "" c.args = reqData[0:0] } else { - c.cmd = strings.ToLower(hack.String(reqData[0])) + c.cmd = hack.String(lowerSlice(reqData[0])) c.args = reqData[1:] } if c.cmd == "quit" { diff --git a/server/util.go b/server/util.go index a243c18..7c5b73d 100644 --- a/server/util.go +++ b/server/util.go @@ -123,3 +123,14 @@ func ReadRequest(in *bufio.Reader, a *arena.Arena) ([][]byte, error) { return req, nil } + +func lowerSlice(buf []byte) []byte { + for i, r := range buf { + if 'A' <= r && r <= 'Z' { + r += 'a' - 'A' + } + + buf[i] = r + } + return buf +}