Skip to content

Commit

Permalink
perf: code
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Nov 30, 2023
1 parent 10e0fdc commit e0dd6d7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func (decode *decode) scanBinaryLen(end int) int {
if decode.pos == end {
break
}
if isNumeric(decode.buf[decode.pos]) {
sum = sum*10 + (int(decode.buf[decode.pos]) - 48)
if isNumeric(decode.current()) {
sum = sum*10 + (int(decode.current()) - 48)
} else {
if decode.buf[decode.pos] == 46 {
if decode.current() == 46 {
break
}
panic(bencodeErorr{error: fmt.Errorf("invalid binary len: wrong char '%s'", string(decode.buf[decode.pos]))})
Expand Down Expand Up @@ -113,7 +113,7 @@ func (decode *decode) next() interface{} {
func (decode *decode) convertDirectory() (directory map[string]interface{}) {
decode.advance()
directory = make(map[string]interface{})
for decode.buf[decode.pos] != EndOfType {
for decode.current() != EndOfType {
binary := decode.convertBinary()
directory[string(binary)] = decode.next()
}
Expand All @@ -122,7 +122,7 @@ func (decode *decode) convertDirectory() (directory map[string]interface{}) {
}
func (decode *decode) convertSlice() (list []interface{}) {
decode.advance()
for decode.buf[decode.pos] != EndOfType {
for decode.current() != EndOfType {
list = append(list, decode.next())
}
decode.advance()
Expand Down

0 comments on commit e0dd6d7

Please sign in to comment.