Skip to content

Commit

Permalink
Merge pull request #24 from ythadhani/optimizeddiff_diffPtr_fix
Browse files Browse the repository at this point in the history
Fixing bug with OptimizedDiff between boolean types
  • Loading branch information
ythadhani authored May 23, 2023
2 parents 49777d1 + 69f30f1 commit 16f8b37
Show file tree
Hide file tree
Showing 3 changed files with 874 additions and 27 deletions.
27 changes: 0 additions & 27 deletions ygot/optimizeddiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func diffField(ni *util.NodeInfo, origValue, modValue reflect.Value, notif *gnmi
switch {
case util.IsValueStructPtr(nonNilValue):
err = diffStructPtr(ni, origValue, modValue, notif)
case util.IsValuePtr(nonNilValue):
err = diffPtr(ni, origValue, modValue, notif)
case util.IsValueStruct(nonNilValue):
err = diffStructs(ni, origValue, modValue, notif)
case util.IsValueMap(nonNilValue):
Expand All @@ -61,31 +59,6 @@ func diffStructPtr(ni *util.NodeInfo, origValue, modValue reflect.Value, notif *
return diffField(ni, newOrigValue, newModValue, notif)
}

func diffPtr(ni *util.NodeInfo, origValue, modValue reflect.Value, notif *gnmipb.Notification) error {
if util.IsNilOrInvalidValue(origValue) {
pathSpec, err := generatePathSpec(ni, modValue)
if err != nil {
return err
}
notif.Update, err = appendUpdate(notif.Update, pathSpec, modValue.Interface())
if err != nil {
return err
}
} else if util.IsNilOrInvalidValue(modValue) {
pathSpec, err := generatePathSpec(ni, origValue)
if err != nil {
return err
}
notif.Delete = append(notif.Delete, pathSpec.gNMIPaths...)
} else {
err := diffField(ni, origValue.Elem(), modValue.Elem(), notif)
if err != nil {
return err
}
}
return nil
}

func diffStructs(ni *util.NodeInfo, origValue, modValue reflect.Value, notif *gnmipb.Notification) error {
var (
nonNilVal reflect.Value = origValue
Expand Down
Loading

0 comments on commit 16f8b37

Please sign in to comment.