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

Commit 8e2b316e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid internal method call and its branching."

parents fe5e954e fe16dfe7
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!"));
    }
}