Skip to content

Commit fcb069f

Browse files
janiszcristaloleg
authored andcommitted
Use bytes.Repeat instead of for loop (#202)
It looks like we reimplemented bytes.Repeat functionality with blob function. Lets use as much code from stdlib as possible.
1 parent 7090562 commit fcb069f

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

bigcache_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,5 @@ func (mc *mockedClock) set(value int64) {
853853
}
854854

855855
func blob(char byte, len int) []byte {
856-
b := make([]byte, len)
857-
for index := range b {
858-
b[index] = char
859-
}
860-
return b
856+
return bytes.Repeat([]byte{char}, len)
861857
}

queue/bytes_queue_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,7 @@ func get(queue *BytesQueue, index int) []byte {
369369
}
370370

371371
func blob(char byte, len int) []byte {
372-
b := make([]byte, len)
373-
for index := range b {
374-
b[index] = char
375-
}
376-
return b
372+
return bytes.Repeat([]byte{char}, len)
377373
}
378374

379375
func assertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) {

0 commit comments

Comments
 (0)