File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ func (t *types) AddNoRepeat(n Type) {
189
189
}
190
190
name := n .Name ()
191
191
i := t .SearchIndex (name )
192
- tt := t .Index (i - 1 )
192
+ tt := t .Index (i )
193
193
if tt == nil || tt .Name () != name {
194
194
t .add (i , n )
195
195
}
@@ -198,29 +198,21 @@ func (t *types) AddNoRepeat(n Type) {
198
198
199
199
func (t * types ) Search (name string ) (Type , bool ) {
200
200
i := t .SearchIndex (name )
201
- if i == 0 {
202
- return nil , false
203
- }
204
- tt := t .Index (i - 1 )
201
+ tt := t .Index (i )
205
202
if tt == nil || tt .Name () != name {
206
203
return nil , false
207
204
}
208
205
return tt , true
209
206
}
210
207
211
208
func (t * types ) SearchIndex (name string ) int {
212
- i := sort .Search (t .Len (), func (i int ) bool {
213
- d := t .Index (i )
214
- if d == nil {
215
- return false
216
- }
217
- return d .Name () < name
209
+ return sort .Search (t .Len (), func (i int ) bool {
210
+ return t .Index (i ).Name () <= name
218
211
})
219
- return i
220
212
}
221
213
222
214
func (t * types ) Index (i int ) Type {
223
- if i >= t .Len () || i < 0 {
215
+ if i >= t .Len () {
224
216
return nil
225
217
}
226
218
return (* t )[i ]
You can’t perform that action at this time.
0 commit comments