فهرست منبع

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