Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe16dfe7 authored by Jake Wharton's avatar Jake Wharton
Browse files

Avoid internal method call and its branching.

This is a simple check that can be done locally.

Test: TextUtilsTest.java
Change-Id: I00f2a4fd087aa98ece2c3aa032e106496663b13f
parent 79b293e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ public class TextUtils {

    /** {@hide} */
    public static int length(@Nullable String s) {
        return isEmpty(s) ? 0 : s.length();
        return s != null ? s.length() : 0;
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -777,4 +777,12 @@ public class TextUtilsTest {
    public void testTrimToSizeThrowsExceptionForZeroSize() {
        TextUtils.trimToSize("abc", 0);
    }

    @Test
    public void length() {
        assertEquals(0, TextUtils.length(null));
        assertEquals(0, TextUtils.length(""));
        assertEquals(2, TextUtils.length("  "));
        assertEquals(6, TextUtils.length("Hello!"));
    }
}