Bug 1381984: Replace StringUtils.join with TextUtils.join. r=liuche
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 18 Jul 2017 13:56:21 -0700
changeset 418758 9c7f4cb53632c82b8edc2271c9303dc5929f7109
parent 418757 ba64040f39ad2656ea5e10d4aced392dce5b75f1
child 418759 7430f157b160e95becfe148ff4f9336c8b28c4df
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1381984
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1381984: Replace StringUtils.join with TextUtils.join. r=liuche I verified the behavior is the same by replacing StringUtils.join with TextUtils.join in the StringUtils.join test (which passed) before deleting it all. MozReview-Commit-ID: 1pmSdTuG0LU
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
@@ -271,28 +271,9 @@ public class StringUtils {
      */
     public static String forceLTR(String text) {
         if (!isRTL(text)) {
             return text;
         }
 
         return "\u200E" + text;
     }
-
-    /**
-     * Joining together a sequence of strings with a separator.
-     */
-    public static String join(@NonNull String separator, @NonNull List<String> parts) {
-        if (parts.size() == 0) {
-            return "";
-        }
-
-        final StringBuilder builder = new StringBuilder();
-        builder.append(parts.get(0));
-
-        for (int i = 1; i < parts.size(); i++) {
-            builder.append(separator);
-            builder.append(parts.get(i));
-        }
-
-        return builder.toString();
-    }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/publicsuffix/PublicSuffix.java
@@ -3,17 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.util.publicsuffix;
 
 import android.content.Context;
 import android.support.annotation.NonNull;
 import android.support.annotation.WorkerThread;
 
-import org.mozilla.gecko.util.StringUtils;
+import android.text.TextUtils;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
 /**
  * Helper methods for the public suffix part of a domain.
@@ -54,17 +54,17 @@ public class PublicSuffix {
      */
     @WorkerThread
     private static int findPublicSuffixIndex(Context context, String domain) {
         final List<String> parts = normalizeAndSplit(domain);
         final int partsSize = parts.size();
         final Set<String> exact = PublicSuffixPatterns.getExactSet(context);
 
         for (int i = 0; i < partsSize; i++) {
-            String ancestorName = StringUtils.join(".", parts.subList(i, partsSize));
+            String ancestorName = TextUtils.join(".", parts.subList(i, partsSize));
 
             if (exact.contains(ancestorName)) {
                 return joinIndex(parts, i);
             }
 
             // Excluded domains (e.g. !nhs.uk) use the next highest
             // domain as the effective public suffix (e.g. uk).
             if (PublicSuffixPatterns.EXCLUDED.contains(ancestorName)) {
--- a/mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/gecko/util/TestStringUtils.java
@@ -99,33 +99,16 @@ public class TestStringUtils {
         assertEquals(4, someRtlString.length());
         final String forcedLtrString = StringUtils.forceLTR(someRtlString);
         assertEquals(5, forcedLtrString.length());
         final String forcedAgainLtrString = StringUtils.forceLTR(forcedLtrString);
         assertEquals(5, forcedAgainLtrString.length());
     }
 
     @Test
-    public void testJoin() {
-        assertEquals("", StringUtils.join("", Collections.<String>emptyList()));
-        assertEquals("", StringUtils.join("-", Collections.<String>emptyList()));
-        assertEquals("", StringUtils.join("", Collections.singletonList("")));
-        assertEquals("", StringUtils.join(".", Collections.singletonList("")));
-
-        assertEquals("192.168.0.1", StringUtils.join(".", Arrays.asList("192", "168", "0", "1")));
-        assertEquals("www.mozilla.org", StringUtils.join(".", Arrays.asList("www", "mozilla", "org")));
-
-        assertEquals("hello", StringUtils.join("", Collections.singletonList("hello")));
-        assertEquals("helloworld", StringUtils.join("", Arrays.asList("hello", "world")));
-        assertEquals("hello world", StringUtils.join(" ", Arrays.asList("hello", "world")));
-
-        assertEquals("m::o::z::i::l::l::a", StringUtils.join("::", Arrays.asList("m", "o", "z", "i", "l", "l", "a")));
-    }
-
-    @Test
     public void testIsSearchQuery(){
         boolean any = true;
         // test trim
         assertFalse(StringUtils.isSearchQuery("",false));
         assertTrue(StringUtils.isSearchQuery("",true));
 
         // test space
         assertTrue(StringUtils.isSearchQuery(" apple pen ",any));