Skip to content

Commit

Permalink
Polish "Fix StringSequence.equals() for different lengths"
Browse files Browse the repository at this point in the history
Closes gh-15465
  • Loading branch information
snicoll committed Dec 17, 2018
1 parent 2a0680c commit c0b07a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || !CharSequence.class.isInstance(obj)) {
if (!(obj instanceof CharSequence)) {
return false;
}
CharSequence other = (CharSequence) obj;
int n = length();
if (n == other.length()) {
int i = 0;
while (n-- != 0) {
if (charAt(i) != other.charAt(i)) {
return false;
}
i++;
if (n != other.length()) {
return false;
}
int i = 0;
while (n-- != 0) {
if (charAt(i) != other.charAt(i)) {
return false;
}
return true;
i++;
}
return false;
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit c0b07a9

Please sign in to comment.