Skip to content

Commit 8f8d1a6

Browse files
committed
no longer cache len(...)
1 parent f38e41d commit 8f8d1a6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

utils.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,17 @@ func parseBinaryDateTime(num uint64, data []byte, loc *time.Location) (driver.Va
505505

506506
func formatBinaryDateTime(src []byte, withTime bool) (driver.Value, error) {
507507
const zeroDateTimeMicros = "0000-00-00 00:00:00.000000"
508-
srclen := len(src)
509508
var dst []byte
510509
if withTime {
511-
if srclen == 11 {
510+
if len(src) == 11 {
512511
dst = []byte(zeroDateTimeMicros)
513512
} else {
514513
dst = []byte(zeroDateTimeMicros[:19])
515514
}
516515
} else {
517516
dst = []byte(zeroDateTimeMicros[:10])
518517
}
519-
switch srclen {
518+
switch len(src) {
520519
case 11:
521520
microsecs := binary.LittleEndian.Uint32(src[7:11])
522521
dst[20] += byte((microsecs / 100000) % 10)
@@ -559,7 +558,7 @@ func formatBinaryDateTime(src []byte, withTime bool) (driver.Value, error) {
559558
} else {
560559
mode = "DATE"
561560
}
562-
return nil, fmt.Errorf("invalid %s-packet length %d", mode, srclen)
561+
return nil, fmt.Errorf("invalid %s-packet length %d", mode, len(src))
563562
}
564563

565564
/******************************************************************************

0 commit comments

Comments
 (0)