MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / compare

Method compare

GPRS/ByteVector.cpp:517–534  ·  view source on GitHub ↗

This is static - there is no 'this' argument.

Source from the content-addressed store, hash-verified

515
516// This is static - there is no 'this' argument.
517int ByteVector::compare(const ByteVector &bv1, const ByteVector &bv2)
518{
519 unsigned bv1size = bv1.sizeBits(), bv2size = bv2.sizeBits();
520 unsigned minsize = MIN(bv1size,bv2size);
521 unsigned bytes = minsize/8;
522 int result;
523 // Compare the full bytes.
524 if (bytes) {
525 if ((result = memcmp(bv1.begin(),bv2.begin(),bytes))) {return result;}
526 }
527 // Compare the partial byte, if any.
528 unsigned rem = minsize%8;
529 if (rem) {
530 if ((result = (int) bv1.getField2(bytes,0,rem) - (int) bv2.getField2(bytes,0,rem))) {return result;}
531 }
532 // All bits the same. The longer guy wins.
533 return (int)bv1size - (int)bv2size;
534}
535
536// We assume that if the last byte is a partial byte (ie bitsize % 8 != 0)
537// then the remaining unused bits are all equal, should be 0.

Callers 4

auditFunction · 0.80
_configFunction · 0.80
configurationCrossCheckFunction · 0.80
getValueMethod · 0.80

Calls 3

sizeBitsMethod · 0.80
getField2Method · 0.80
beginMethod · 0.45

Tested by

no test coverage detected