diff options
| author | 2024-02-01 00:02:55 +0000 | |
|---|---|---|
| committer | 2024-02-01 00:02:55 +0000 | |
| commit | 5553ef63be67e799f45f36082fc33dc48f4be83f (patch) | |
| tree | d3fdecdbe65b906cdb4adee9b3c8a2479993a078 | |
| parent | dae585075659a9a0d02cf737cba4179105e3e506 (diff) | |
| parent | 7c19b3cc10b662ecf42561f1013ecb5b53cd46c3 (diff) | |
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
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 2 | ||||
| -rw-r--r-- | core/java/android/content/res/ResourcesImpl.java | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 5d2a26e13ee7..4c54b03bd6d6 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -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 diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java index c7790bd96c62..5e442b819774 100644 --- a/core/java/android/content/res/ResourcesImpl.java +++ b/core/java/android/content/res/ResourcesImpl.java @@ -273,14 +273,27 @@ 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"); } - try { - return Integer.parseInt(name); - } catch (Exception e) { - // Ignore + if (isIntLike(name)) { + try { + return Integer.parseInt(name); + } catch (Exception e) { + // Ignore + } } return mAssets.getResourceIdentifier(name, defType, defPackage); } |