Skip to content

Commit 5079f1c

Browse files
committed
removed unnecessary switch construct
1 parent 1978a3c commit 5079f1c

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

utils.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,35 +192,28 @@ func readLengthEncodedInteger(b []byte) (num uint64, isNull bool, n int) {
192192

193193
// 252: value of following 2
194194
case 0xfc:
195+
num = uint64(b[1]) | uint64(b[2])<<8
195196
n = 3
197+
return
196198

197199
// 253: value of following 3
198200
case 0xfd:
201+
num = uint64(b[1]) | uint64(b[2])<<8 | uint64(b[3])<<16
199202
n = 4
203+
return
200204

201205
// 254: value of following 8
202206
case 0xfe:
203-
n = 9
204-
205-
// 0-250: value of first byte
206-
default:
207-
num = uint64(b[0])
208-
n = 1
209-
return
210-
}
211-
212-
switch n - 1 {
213-
case 2:
214-
num = uint64(b[1]) | uint64(b[2])<<8
215-
return
216-
case 3:
217-
num = uint64(b[1]) | uint64(b[2])<<8 | uint64(b[3])<<16
218-
return
219-
default:
220207
num = uint64(b[1]) | uint64(b[2])<<8 | uint64(b[3])<<16 |
221208
uint64(b[4])<<24 | uint64(b[5])<<32 | uint64(b[6])<<40 |
222209
uint64(b[7])<<48 | uint64(b[8])<<54
210+
n = 9
211+
return
223212
}
213+
214+
// 0-250: value of first byte
215+
num = uint64(b[0])
216+
n = 1
224217
return
225218
}
226219

0 commit comments

Comments
 (0)