forked from mirror/ledisdb
optimize codes
This commit is contained in:
parent
b47e49d6fd
commit
44e93ba921
|
@ -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" {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue