optimize codes

This commit is contained in:
siddontang 2014-10-30 12:48:52 +08:00
parent b47e49d6fd
commit 44e93ba921
2 changed files with 12 additions and 2 deletions

View File

@ -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" {

View File

@ -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
}