File tree 1 file changed +1
-12
lines changed
1 file changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -2,30 +2,21 @@ package redis
2
2
3
3
import (
4
4
"context"
5
- "sync"
6
5
)
7
6
8
7
// ScanIterator is used to incrementally iterate over a collection of elements.
9
- // It's safe for concurrent use by multiple goroutines.
10
8
type ScanIterator struct {
11
- mu sync.Mutex // protects Scanner and pos
12
9
cmd * ScanCmd
13
10
pos int
14
11
}
15
12
16
13
// Err returns the last iterator error, if any.
17
14
func (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 ()
22
16
}
23
17
24
18
// Next advances the cursor and returns true if more values can be read.
25
19
func (it * ScanIterator ) Next (ctx context.Context ) bool {
26
- it .mu .Lock ()
27
- defer it .mu .Unlock ()
28
-
29
20
// Instantly return on errors.
30
21
if it .cmd .Err () != nil {
31
22
return false
@@ -68,10 +59,8 @@ func (it *ScanIterator) Next(ctx context.Context) bool {
68
59
// Val returns the key/field at the current cursor position.
69
60
func (it * ScanIterator ) Val () string {
70
61
var v string
71
- it .mu .Lock ()
72
62
if it .cmd .Err () == nil && it .pos > 0 && it .pos <= len (it .cmd .page ) {
73
63
v = it .cmd .page [it .pos - 1 ]
74
64
}
75
- it .mu .Unlock ()
76
65
return v
77
66
}
You can’t perform that action at this time.
0 commit comments