Browse Source

Better stringbuilder comparison

master
anthony restaino 8 years ago
parent
commit
fa7673b3d1
  1. 3
      app/src/main/java/acr/browser/lightning/app/AppComponent.java
  2. 15
      app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java

3
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -1,7 +1,5 @@
package acr.browser.lightning.app; package acr.browser.lightning.app;
import android.support.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import acr.browser.lightning.activity.BrowserActivity; import acr.browser.lightning.activity.BrowserActivity;
@ -23,7 +21,6 @@ import acr.browser.lightning.fragment.LightningPreferenceFragment;
import acr.browser.lightning.fragment.PrivacySettingsFragment; import acr.browser.lightning.fragment.PrivacySettingsFragment;
import acr.browser.lightning.fragment.TabsFragment; import acr.browser.lightning.fragment.TabsFragment;
import acr.browser.lightning.search.SuggestionsAdapter; import acr.browser.lightning.search.SuggestionsAdapter;
import acr.browser.lightning.utils.AdBlock;
import acr.browser.lightning.utils.ProxyUtils; import acr.browser.lightning.utils.ProxyUtils;
import acr.browser.lightning.view.LightningChromeClient; import acr.browser.lightning.view.LightningChromeClient;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;

15
app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java

@ -93,8 +93,19 @@ public class StringBuilderUtils {
* the string builder is equal to the string. * the string builder is equal to the string.
*/ */
public static boolean equals(@NonNull StringBuilder stringBuilder, @NonNull String equal) { public static boolean equals(@NonNull StringBuilder stringBuilder, @NonNull String equal) {
int index = stringBuilder.indexOf(equal);
return index >= 0 && stringBuilder.length() == equal.length(); int builderLength = stringBuilder.length();
if (builderLength != equal.length()) {
return false;
}
for (int n = 0; n < builderLength; n++) {
if (stringBuilder.charAt(n) != equal.charAt(n)) {
return false;
}
}
return true;
} }
/** /**

Loading…
Cancel
Save