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

Commit 5553ef63 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Android (Google) Code Review
Browse files

Merge changes I1cd6be72,If8929785 into main

* changes:
  [res] Speed up a check of a resource name for int
  [res] Disable verbose logging for assets changes
parents dae58507 7c19b3cc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ public final class ActivityThread extends ClientTransactionHandler
    public static final boolean DEBUG_MEMORY_TRIM = false;
    private static final boolean DEBUG_PROVIDER = false;
    public static final boolean DEBUG_ORDER = false;
    private static final boolean DEBUG_APP_INFO = true;
    private static final boolean DEBUG_APP_INFO = false;
    private static final long MIN_TIME_BETWEEN_GCS = 5*1000;
    /**
     * The delay to release the provider when it has no more references. It reduces the number of
+17 −4
Original line number Diff line number Diff line
@@ -273,15 +273,28 @@ public class ResourcesImpl {
        throw new NotFoundException("String resource name " + name);
    }

    private static boolean isIntLike(@NonNull String s) {
        if (s.isEmpty() || s.length() > 10) return false;
        for (int i = 0, size = s.length(); i < size; i++) {
            final char c = s.charAt(i);
            if (c < '0' || c > '9') {
                return false;
            }
        }
        return true;
    }

    int getIdentifier(String name, String defType, String defPackage) {
        if (name == null) {
            throw new NullPointerException("name is null");
        }
        if (isIntLike(name)) {
            try {
                return Integer.parseInt(name);
            } catch (Exception e) {
                // Ignore
            }
        }
        return mAssets.getResourceIdentifier(name, defType, defPackage);
    }