Skip to content

Commit

Permalink
fix: remove _skipAbsent labels
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Apr 25, 2023
1 parent aea45fc commit 9f519f1
Showing 1 changed file with 40 additions and 38 deletions.
78 changes: 40 additions & 38 deletions node/bindnode/repr.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ type _tupleIteratorRepr struct {
}

func (w *_tupleIteratorRepr) Next() (index int64, value datamodel.Node, _ error) {
_skipAbsent:
idx := w.nextIndex
_, value, err := (*_structIterator)(w).Next()
if err != nil {
return 0, nil, err
}
if w.nextIndex > w.reprEnd {
goto _skipAbsent
for {
idx := w.nextIndex
_, value, err := (*_structIterator)(w).Next()
if err != nil {
return 0, nil, err
}
if w.nextIndex <= w.reprEnd {
return int64(idx), reprNode(value), nil
}
}
return int64(idx), reprNode(value), nil
}

func (w *_tupleIteratorRepr) Done() bool {
Expand All @@ -372,23 +372,24 @@ type _listpairsIteratorRepr struct {
}

func (w *_listpairsIteratorRepr) Next() (index int64, value datamodel.Node, _ error) {
_skipAbsent:
if w.Done() {
return 0, nil, datamodel.ErrIteratorOverread{}
}
idx := w.nextIndex
key, value, err := (*_structIterator)(w).Next()
if err != nil {
return 0, nil, err
}
if value.IsAbsent() || w.nextIndex > w.reprEnd {
goto _skipAbsent
}
field, err := buildListpairsField(key, value)
if err != nil {
return 0, nil, err
for {
if w.Done() {
return 0, nil, datamodel.ErrIteratorOverread{}
}
idx := w.nextIndex
key, value, err := (*_structIterator)(w).Next()
if err != nil {
return 0, nil, err
}
if value.IsAbsent() || w.nextIndex > w.reprEnd {
continue
}
field, err := buildListpairsField(key, value)
if err != nil {
return 0, nil, err
}
return int64(idx), field, nil
}
return int64(idx), field, nil
}

func (w *_listpairsIteratorRepr) Done() bool {
Expand Down Expand Up @@ -1257,20 +1258,21 @@ type _structIteratorRepr _structIterator
func (w *_structIteratorRepr) Next() (key, value datamodel.Node, _ error) {
switch stg := reprStrategy(w.schemaType).(type) {
case schema.StructRepresentation_Map:
_skipAbsent:
key, value, err := (*_structIterator)(w).Next()
if err != nil {
return nil, nil, err
}
if value.IsAbsent() {
goto _skipAbsent
}
keyStr, _ := key.AsString()
mappedKey := outboundMappedKey(stg, keyStr)
if mappedKey != keyStr {
key = basicnode.NewString(mappedKey)
for {
key, value, err := (*_structIterator)(w).Next()
if err != nil {
return nil, nil, err
}
if value.IsAbsent() {
continue
}
keyStr, _ := key.AsString()
mappedKey := outboundMappedKey(stg, keyStr)
if mappedKey != keyStr {
key = basicnode.NewString(mappedKey)
}
return key, reprNode(value), nil
}
return key, reprNode(value), nil
default:
return nil, nil, fmt.Errorf("bindnode Next TODO: %T", stg)
}
Expand Down

0 comments on commit 9f519f1

Please sign in to comment.