Переглянути джерело

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 - 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;
                 }
             }