Skip to content

Commit 4068613

Browse files
committed
use builtin min function
1 parent 42c80c6 commit 4068613

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

protocol/codec_tester.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ func randomizeValue(v reflect.Value, depth int, datapath string, tag string, rem
382382
// we don't want to allocate a slice with size of 0. This is because decoding and encoding this slice
383383
// will result in nil and not slice of size 0
384384
maxLen := 31
385-
if cfg.MaxCollectionLen > 0 && cfg.MaxCollectionLen < maxLen {
386-
maxLen = cfg.MaxCollectionLen
385+
if cfg.MaxCollectionLen > 0 {
386+
maxLen = min(maxLen, cfg.MaxCollectionLen)
387387
}
388388
l := rand.Intn(maxLen) + 1
389389

@@ -414,10 +414,7 @@ func randomizeValue(v reflect.Value, depth int, datapath string, tag string, rem
414414
maxLen := 32
415415
if cfg.MaxCollectionLen > 0 {
416416
// preserve possibility of zero entries while capping positive lengths
417-
capLen := cfg.MaxCollectionLen + 1
418-
if capLen < maxLen {
419-
maxLen = capLen
420-
}
417+
maxLen = min(maxLen, cfg.MaxCollectionLen+1)
421418
}
422419
l := rand.Intn(maxLen)
423420
if hasAllocBound {

0 commit comments

Comments
 (0)