Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: build/android/gyp/process_resources.py

Issue 2573613002: Shrink onResourcesLoaded() code size in webview/monochrome R.java (Closed)
Patch Set: Format Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/process_resources.py
diff --git a/build/android/gyp/process_resources.py b/build/android/gyp/process_resources.py
index 2d4638f8d81f77dca0dacb705e4ca9fbdc5959cf..7de5bffdc9a27ff332d65808abe83e6f25cf98d9 100755
--- a/build/android/gyp/process_resources.py
+++ b/build/android/gyp/process_resources.py
@@ -200,11 +200,10 @@ def _CreateRJavaFile(package, resources_by_type, shared_resources):
# Keep these assignments all on one line to make diffing against regular
# aapt-generated files easier.
create_id = ('{{ e.resource_type }}.{{ e.name }} = '
agrieve 2016/12/12 20:40:51 nit: could now shorten these with ^=
F 2016/12/12 21:13:12 Done.
- '({{ e.resource_type }}.{{ e.name }} & 0x00ffffff) |'
- ' (packageId << 24);')
+ '{{ e.resource_type }}.{{ e.name }} ^ packageIdTransform;')
create_id_arr = ('{{ e.resource_type }}.{{ e.name }}[i] = '
- '({{ e.resource_type }}.{{ e.name }}[i] & 0x00ffffff) |'
- ' (packageId << 24);')
+ '{{ e.resource_type }}.{{ e.name }}[i] ^'
+ ' packageIdTransform;')
# Here we diverge from what aapt does. Because we have so many
# resources, the onResourcesLoaded method was exceeding the 64KB limit that
# Java imposes. For this reason we split onResourcesLoaded into different
@@ -227,8 +226,11 @@ public final class R {
{% endfor %}
{% if shared_resources %}
public static void onResourcesLoaded(int packageId) {
+ assert !sResourcesDidLoad;
+ sResourcesDidLoad = true;
+ int packageIdTransform = (packageId ^ 0x7f) << 24;
{% for resource_type in resource_types %}
- onResourcesLoaded{{ resource_type|title }}(packageId);
+ onResourcesLoaded{{ resource_type|title }}(packageIdTransform);
{% for e in resources[resource_type] %}
{% if e.java_type == 'int[]' %}
for(int i = 0; i < {{ e.resource_type }}.{{ e.name }}.length; ++i) {
@@ -238,8 +240,10 @@ public final class R {
{% endfor %}
{% endfor %}
}
+ private static boolean sResourcesDidLoad;
agrieve 2016/12/12 20:40:51 nit: can you move this to come at the top of the c
F 2016/12/12 21:13:13 Done.
{% for res_type in resource_types %}
- private static void onResourcesLoaded{{ res_type|title }}(int packageId) {
+ private static void onResourcesLoaded{{ res_type|title }} (
+ int packageIdTransform) {
agrieve 2016/12/12 20:40:51 nit: indent 4 more spaces
F 2016/12/12 21:13:13 Done.
{% for e in resources[res_type] %}
{% if res_type != 'styleable' and e.java_type != 'int[]' %}
""" + create_id + """
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698