瀏覽代碼

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 6 年之前
父節點
當前提交
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;
                 }
             }