Bug 1381984: Replace StringUtils.join with TextUtils.join. r=liuche
☠☠ backed out by 02b3fd4876ff ☠ ☠
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 18 Jul 2017 13:56:21 -0700
changeset 418478 d38c3ad6fe5b2af851f7d5b033e9b60d9075ec6b
parent 418477 0410c249a52a726cbbd6c99d27f7e3d8ee421ee4
child 418479 7a5b159fa4495bb4e29e751a05d24c434479a414
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
@@ -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));