MCPcopy Index your code
hub / github.com/apache/tomcat / compare

Method compare

java/org/apache/tomcat/util/buf/StringCache.java:508–534  ·  view source on GitHub ↗

Compare given byte chunk with byte array. @param name The name to compare @param compareTo The compared to data @return -1, 0 or +1 if inferior, equal, or superior to the String.

(ByteChunk name, byte[] compareTo)

Source from the content-addressed store, hash-verified

506 * @return -1, 0 or +1 if inferior, equal, or superior to the String.
507 */
508 protected static int compare(ByteChunk name, byte[] compareTo) {
509 int result = 0;
510
511 byte[] b = name.getBuffer();
512 int start = name.getStart();
513 int end = name.getEnd();
514 int len = compareTo.length;
515
516 if ((end - start) < len) {
517 len = end - start;
518 }
519 for (int i = 0; (i < len) && (result == 0); i++) {
520 if (b[i + start] > compareTo[i]) {
521 result = 1;
522 } else if (b[i + start] < compareTo[i]) {
523 result = -1;
524 }
525 }
526 if (result == 0) {
527 if (compareTo.length > (end - start)) {
528 result = -1;
529 } else if (compareTo.length < (end - start)) {
530 result = 1;
531 }
532 }
533 return result;
534 }
535
536
537 /**

Callers 3

findMethod · 0.95
findClosestMethod · 0.95
compareToMethod · 0.45

Calls 3

getBufferMethod · 0.65
getStartMethod · 0.45
getEndMethod · 0.45

Tested by

no test coverage detected