Skip to content

Commit

Permalink
statements.fill() can no-longer return an error
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Sep 9, 2016
1 parent 5e38da6 commit 71963a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 5 additions & 12 deletions statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ func statementsFromJSON(r io.Reader) (statements, error) {
return nil, err
}
ss := make(statements, 0, 32)
err = ss.fill(statement{{"json", typBare}}, top)
return ss, err
ss.fill(statement{{"json", typBare}}, top)
return ss, nil
}

// fill takes a prefix statement and some value and recursively fills
// the statement list using that value
func (ss *statements) fill(prefix statement, v interface{}) error {
func (ss *statements) fill(prefix statement, v interface{}) {

// Add a statement for the current prefix and value
ss.Add(prefix, valueTokenFromInterface(v))
Expand All @@ -232,21 +232,14 @@ func (ss *statements) fill(prefix statement, v interface{}) error {
} else {
newPrefix = prefix.withQuotedKey(k)
}
err := ss.fill(newPrefix, sub)
if err != nil {
return err
}
ss.fill(newPrefix, sub)
}

case []interface{}:
// It's an array
for k, sub := range vv {
err := ss.fill(prefix.withNumericKey(k), sub)
if err != nil {
return err
}
ss.fill(prefix.withNumericKey(k), sub)
}
}

return nil
}
2 changes: 1 addition & 1 deletion statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func BenchmarkFill(b *testing.B) {

for i := 0; i < b.N; i++ {
ss := make(statements, 0)
_ = ss.fill(statement{{"json", typBare}}, top)
ss.fill(statement{{"json", typBare}}, top)
}
}

Expand Down

0 comments on commit 71963a2

Please sign in to comment.