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

Commit 0388f0e5 authored by Jiabin's avatar Jiabin
Browse files

TIF: optimize android.media.tv.Tvcontract.Programs.Genres#decode

test result:
 Decode function takes about 0.25 seconds with 1350 channels in Live Channels.
 The original one takes about 0.37 seconds in the same test case.

Bug: 23307587
Change-Id: I3a1fefe0b3e6c1986c8f515259658f2e3e23011f
parent 2e5cdb52
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1314,6 +1314,8 @@ public final class TvContract {
            private static final char COMMA = ',';
            private static final String DELIMITER = ",";

            private static final String[] EMPTY_STRING_ARRAY = new String[0];

            private Genres() {}

            /**
@@ -1359,6 +1361,12 @@ public final class TvContract {
             * @return genre strings.
             */
            public static String[] decode(String genres) {
                if (genres.isEmpty()) {
                    return EMPTY_STRING_ARRAY;
                }
                if (genres.indexOf(COMMA) == -1 && genres.indexOf(DOUBLE_QUOTE) == -1) {
                    return new String[] {genres.trim()};
                }
                StringBuilder sb = new StringBuilder();
                List<String> results = new ArrayList<>();
                int length = genres.length();