compareCacheStoreKeys function

int compareCacheStoreKeys(
  1. List<int> a,
  2. List<int> b
)

Compares two keys in the order of a CacheStore: by their unsigned bytes, the first differing byte deciding, and a key that is a prefix of another before it. For stores that keep their keys in a Dart collection (a SplayTreeMap with this as its comparator, for example).

Implementation

int compareCacheStoreKeys(List<int> a, List<int> b) {
  final int length = a.length < b.length ? a.length : b.length;
  for (int i = 0; i < length; i++) {
    final int difference = a[i] - b[i];
    if (difference != 0) {
      return difference;
    }
  }
  return a.length - b.length;
}