소스 검색

authentication: Use equalsIgnoreCase() instead of convoluted toLowerCase()

Using toLowerCase() or toUpperCase() to make case insensitive comparisons is inefficient because it requires the creation of temporary, intermediate String objects.

In this case, it also made the fi statement complex and difficult to read.
ardevd 7 년 전
부모
커밋
75d10d6afb
1개의 변경된 파일1개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 3
      src/main/java/com/owncloud/android/authentication/AccountUtils.java

+ 1 - 3
src/main/java/com/owncloud/android/authentication/AccountUtils.java

@@ -111,14 +111,12 @@ public class AccountUtils {
             String username = account.name.substring(0, lastAtPos);
             String otherHostAndPort;
             String otherUsername;
-            Locale currentLocale = context.getResources().getConfiguration().locale;
             for (Account otherAccount : ocAccounts) {
                 lastAtPos = otherAccount.name.lastIndexOf("@");
                 otherHostAndPort = otherAccount.name.substring(lastAtPos + 1);
                 otherUsername = otherAccount.name.substring(0, lastAtPos);
                 if (otherHostAndPort.equals(hostAndPort) &&
-                        otherUsername.toLowerCase(currentLocale).
-                            equals(username.toLowerCase(currentLocale))) {
+                        otherUsername.equalsIgnoreCase(username)) {
                     return true;
                 }
             }