File tree Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -2,30 +2,21 @@ package redis
22
33import (
44 "context"
5- "sync"
65)
76
87// ScanIterator is used to incrementally iterate over a collection of elements.
9- // It's safe for concurrent use by multiple goroutines.
108type ScanIterator struct {
11- mu sync.Mutex // protects Scanner and pos
129 cmd * ScanCmd
1310 pos int
1411}
1512
1613// Err returns the last iterator error, if any.
1714func (it * ScanIterator ) Err () error {
18- it .mu .Lock ()
19- err := it .cmd .Err ()
20- it .mu .Unlock ()
21- return err
15+ return it .cmd .Err ()
2216}
2317
2418// Next advances the cursor and returns true if more values can be read.
2519func (it * ScanIterator ) Next (ctx context.Context ) bool {
26- it .mu .Lock ()
27- defer it .mu .Unlock ()
28-
2920 // Instantly return on errors.
3021 if it .cmd .Err () != nil {
3122 return false
@@ -68,10 +59,8 @@ func (it *ScanIterator) Next(ctx context.Context) bool {
6859// Val returns the key/field at the current cursor position.
6960func (it * ScanIterator ) Val () string {
7061 var v string
71- it .mu .Lock ()
7262 if it .cmd .Err () == nil && it .pos > 0 && it .pos <= len (it .cmd .page ) {
7363 v = it .cmd .page [it .pos - 1 ]
7464 }
75- it .mu .Unlock ()
7665 return v
7766}
You can’t perform that action at this time.
0 commit comments