Skip to content

Commit

Permalink
Fixes GetNodeByOID
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepinggenius2 committed Jul 11, 2019
1 parent c234272 commit c1e4b64
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions smi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,14 @@ func GetNodeByOID(oid types.Oid) *types.SmiNode {
if len(oid) == 0 || internal.Root() == nil {
return nil
}
var (
i int
parentPtr, nodePtr *internal.Node
)
nodePtr = internal.Root()
for i < len(oid) {
var parentPtr, nodePtr *internal.Node = nil, internal.Root()
for i := 0; i < len(oid) && nodePtr != nil; i++ {
parentPtr, nodePtr = nodePtr, nodePtr.Children.Get(oid[i])
if nodePtr == nil {
if parentPtr.FirstObject == nil {
return nil
}
return parentPtr.FirstObject.GetSmiNode()
}
}
if nodePtr.FirstObject == nil {
if nodePtr == nil {
nodePtr = parentPtr
}
if nodePtr == nil || nodePtr.FirstObject == nil {
return nil
}
return nodePtr.FirstObject.GetSmiNode()
Expand Down

0 comments on commit c1e4b64

Please sign in to comment.