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

Function Compare

pkg/util/bitarray/bitarray.go:449–481  ·  view source on GitHub ↗

Compare compares two bit arrays. They can have mixed sizes.

(lhs, rhs BitArray)

Source from the content-addressed store, hash-verified

447
448// Compare compares two bit arrays. They can have mixed sizes.
449func Compare(lhs, rhs BitArray) int {
450 n := len(lhs.words)
451 if n > len(rhs.words) {
452 n = len(rhs.words)
453 }
454 i := 0
455 for ; i < n; i++ {
456 lw := lhs.words[i]
457 rw := rhs.words[i]
458 if lw < rw {
459 return -1
460 }
461 if lw > rw {
462 return 1
463 }
464 }
465 if i < len(rhs.words) {
466 // lhs is shorter.
467 return -1
468 }
469 if i < len(lhs.words) {
470 // rhs is shorter.
471 return 1
472 }
473 // Same length.
474 if lhs.lastBitsUsed < rhs.lastBitsUsed {
475 return -1
476 }
477 if lhs.lastBitsUsed > rhs.lastBitsUsed {
478 return 1
479 }
480 return 0
481}
482
483// EncodingParts retrieves the encoding bits from the bit array. The
484// words are presented in big-endian order, with the leftmost bits of

Callers 1

CompareMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…