Description
The methods equals and equalsIgnoreCase in StringUtils are essentially the same method but one is case insensitive. However the method arguments have different names, the edge case check logic is different (with the same effect) and the javadocs are slightly different.
The equals method also calls a CharSequenceUtils helper method which is unnecessary as that contains functionality that is not used, i.e. the case insensitivity. This can be updated to just do a simple step-wise charAt comparison through the entire CharSequence:
final int length = cs1.length(); for (int i = 0; i < length; i++) { if (cs1.charAt(i) != cs2.charAt(i)) { return false; } }
The result is code that does the same as before but is cleaner to understand.
This change will consolidate the two methods to improve the similarity in both the documentation and the implementation:
- Update the parameter names to match
- Update the Javadoc to match with the exception of case sensitivity
- Update the edge case logic to match in the implementation
- Update to use a step-wise charAt comparison