MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Compare

Method Compare

pkg/util/json/json.go:700–721  ·  view source on GitHub ↗
(other JSON)

Source from the content-addressed store, hash-verified

698}
699
700func (j jsonString) Compare(other JSON) (int, error) {
701 if isEmptyArray(other) {
702 return 1, nil
703 }
704 cmp := cmpJSONTypes(j.Type(), other.Type())
705 if cmp != 0 {
706 return cmp, nil
707 }
708 // TODO(justin): we should optimize this, we don't have to decode the whole thing.
709 var err error
710 if other, err = decodeIfNeeded(other); err != nil {
711 return 0, err
712 }
713 o := other.(jsonString)
714 if o > j {
715 return -1, nil
716 }
717 if o < j {
718 return 1, nil
719 }
720 return 0, nil
721}
722
723func (j jsonArray) Compare(other JSON) (int, error) {
724 switch {

Callers 1

slowContainsMethod · 0.95

Calls 5

TypeMethod · 0.95
isEmptyArrayFunction · 0.85
cmpJSONTypesFunction · 0.85
decodeIfNeededFunction · 0.85
TypeMethod · 0.65

Tested by

no test coverage detected