tailEqualsLength method

int tailEqualsLength(
  1. String other
)

Returns the length of the tail that is equals to the tail of other.

Implementation

int tailEqualsLength(String other) {
  var l1 = this.length;
  var l2 = other.length;

  var length = math.min(l1, l2);

  --l1;
  --l2;

  for (var i = 0; i < length; ++i) {
    var c1 = this[l1 - i];
    var c2 = other[l2 - i];

    if (c1 != c2) {
      return i;
    }
  }

  return length;
}