Commit c0b07a94 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Fix StringSequence.equals() for different lengths"

Closes gh-15465
parent 2a0680c2
...@@ -111,22 +111,22 @@ final class StringSequence implements CharSequence { ...@@ -111,22 +111,22 @@ final class StringSequence implements CharSequence {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null || !CharSequence.class.isInstance(obj)) { if (!(obj instanceof CharSequence)) {
return false; return false;
} }
CharSequence other = (CharSequence) obj; CharSequence other = (CharSequence) obj;
int n = length(); int n = length();
if (n == other.length()) { if (n != other.length()) {
int i = 0; return false;
while (n-- != 0) { }
if (charAt(i) != other.charAt(i)) { int i = 0;
return false; while (n-- != 0) {
} if (charAt(i) != other.charAt(i)) {
i++; return false;
} }
return true; i++;
} }
return false; return true;
} }
@Override @Override
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment