anchor.diff:      }
   
       while (index < length) {
  -
         // Normalize percent-encoding to uppercase and don't encode
         // unreserved characters.
  -      if (component.codeUnitAt(index) == _PERCENT) {
  -        if (length < index + 2) {
  -            throw new ArgumentError(
  -                "Invalid percent-encoding in URI component: $component");
  +      assert(component.codeUnitAt(index) == _PERCENT);
  +      if (length < index + 2) {
  +          throw new ArgumentError(
  +              "Invalid percent-encoding in URI component: $component");
  +      }
  +
  +      var codeUnit1 = component.codeUnitAt(index + 1);
  +      var codeUnit2 = component.codeUnitAt(index + 2);
  +      var decodedCodeUnit = decodeHexDigitPair(index + 1);
  +      if (isNormalizedHexDigit(codeUnit1) &&
  +          isNormalizedHexDigit(codeUnit2) &&
  +          !isUnreserved(decodedCodeUnit)) {
  +        index += 3;
  +      } else {
  +        fillResult();
  +        if (isUnreserved(decodedCodeUnit)) {
  +          result.writeCharCode(decodedCodeUnit);
  +        } else {
  +          result.write("%");
  +          result.writeCharCode(normalizeHexDigit(index + 1));
  +          result.writeCharCode(normalizeHexDigit(index + 2));
           }
  -
  -        var codeUnit1 = component.codeUnitAt(index + 1);
  -        var codeUnit2 = component.codeUnitAt(index + 2);
  -        var decodedCodeUnit = decodeHexDigitPair(index + 1);
  -        if (isNormalizedHexDigit(codeUnit1) &&
  -            isNormalizedHexDigit(codeUnit2) &&
  -            !isUnreserved(decodedCodeUnit)) {
  -          index += 3;
  -        } else {
  -          fillResult();
  -          if (isUnreserved(decodedCodeUnit)) {
  -            result.writeCharCode(decodedCodeUnit);
  -          } else {
  -            result.write("%");
  -            result.writeCharCode(normalizeHexDigit(index + 1));
  -            result.writeCharCode(normalizeHexDigit(index + 2));
  -          }
  -          index += 3;
  -          prevIndex = index;
  -        }
  +        index += 3;
  +        prevIndex = index;
  +      }
  +      int next = component.indexOf('%', index);
  +      if (next >= index) {
  +        index = next;
         } else {
  -        index++;
  -      }
  -    }
  +        index = length;
  +      }
  +    }
  +    if (result == null) return component;
  +
       if (result != null && prevIndex != index) fillResult();
       assert(index == length);
   
  -    if (result == null) return component;
       return result.toString();
     }
   
  
positive.code:   }
  
    static String _normalize(String component) {
      bool isNormalizedHexDigit(int digit) {
        return (_ZERO <= digit && digit <= _NINE) ||
            (_UPPER_CASE_A <= digit && digit <= _UPPER_CASE_F);
  
negative.code:     // Start building the normalized component string.
      StringBuffer result;
      int length = component.length;
      int prevIndex = 0;
  
      // Copy a part of the component string to the result.
  