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

Commit aeb82d14 authored by Steve Kondik's avatar Steve Kondik
Browse files

Attempt to minimize GC when processing BiDi

Change-Id: I5d7102e5f1ce17378d9a0b304cca7b404262892b
parent 95a08f9e
Loading
Loading
Loading
Loading
+23 −21
Original line number Diff line number Diff line
@@ -1732,7 +1732,7 @@ public class TextUtils {
    /**
     * @hide
     */
    public static boolean isRTLCharacter(char c) {
    private static boolean isRTLCharacter(char c) {
        //range of RTL characters per unicode specification
        return (c >= 0x0590 && c <= 0x05FF) ||
               (c >= 0xFB1D && c <= 0xFB4F) ||
@@ -1745,7 +1745,7 @@ public class TextUtils {
     * function to check if text range has RTL characters.
     * @hide
     */
    public static boolean hasRTLCharacters(final char[] text, int start, int end) {
    private static boolean hasRTLCharacters(final char[] text, int start, int end) {
        if (text == null)
            return false;

@@ -1782,7 +1782,7 @@ public class TextUtils {
     * @hide
     */
    public static String processBidi(final String src) {
        return (TextUtils.processBidi(src, 0, src.length()));
        return src == null ? null : TextUtils.processBidi(src, 0, src.length());
    }

    /**
@@ -1792,8 +1792,7 @@ public class TextUtils {
     * @hide
     */
    public static char[] processBidi(final char[] src) {

        return (TextUtils.processBidi(src, 0, src.length));
        return src == null ? null : TextUtils.processBidi(src, 0, src.length);
    }

    /**
@@ -1805,10 +1804,7 @@ public class TextUtils {
     * @hide
     */
    public static String processBidi(final String src, int start, int end) {

        char[] chars2 = TextUtils.processBidi(src.toCharArray(), start, end);

        return (new String(chars2));
        return src != null && hasRTLCharacters(src, start, end) ? String.valueOf(TextUtils.processBidi(src.toCharArray(), start, end)) : src;
    }

    /**
@@ -1821,13 +1817,19 @@ public class TextUtils {
     * @hide
     */
    public static char[] processBidi(final char[] src, int start, int end) {
        return src != null && hasRTLCharacters(src, start, end) ? processBidiChars(src, start, end) : src;
    }

        if (src == null)
            return (src);

        //if there are no right-to-left characters
        if (!hasRTLCharacters(src,start,end))
            return (src);
    /**
     * function to process bidi on the given text
     * @author: Eyad Aboulouz
     * @param src
     * @param start
     * @param end
     * @return char[]
     * @hide
     */
    private static char[] processBidiChars(final char[] src, int start, int end) {

        try {
            char[] outputTxt = new char[end-start];