Skip to content

Commit

Permalink
encoding/openapi: remove unused code
Browse files Browse the repository at this point in the history
When refactoring cue/load, I noticed that some pieces of code
were unused, which makes it less obvious what kinds of things
can be done. I used `staticcheck` to point out many other
places in the code that are unused.

This is one of those places.  I feel it's better to remove this code
even if it might be used in the future (it's always there to be found
in the git history).

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I7a2ee05fcc8a36140e07bea8162f97d0854e26ec
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549295
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
rogpeppe authored and mvdan committed May 25, 2023
1 parent 8868ae6 commit 36645d1
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions encoding/openapi/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type buildContext struct {
nameFunc func(inst cue.Value, path cue.Path) string
descFunc func(v cue.Value) string
fieldFilter *regexp.Regexp
evalDepth int // detect cycles when resolving references

schemas *OrderedMap

Expand Down Expand Up @@ -519,28 +518,6 @@ outer:
return a
}

func countNodes(v cue.Value) (n int) {
switch op, a := v.Expr(); op {
case cue.OrOp, cue.AndOp:
for _, v := range a {
n += countNodes(v)
}
n += len(a) - 1
default:
switch v.Kind() {
case cue.ListKind:
for i, _ := v.List(); i.Next(); {
n += countNodes(i.Value())
}
case cue.StructKind:
for i, _ := v.Fields(); i.Next(); {
n += countNodes(i.Value()) + 1
}
}
}
return n + 1
}

// isConcrete reports whether v is concrete and not a struct (recursively).
// structs are not supported as the result of a struct enum depends on how
// conjunctions and disjunctions are distributed. We could consider still doing
Expand Down

0 comments on commit 36645d1

Please sign in to comment.