Factor out repeated shift instructions to reduce code size

R8 has some O(n^3) analysis somewhere, so this should speed up analysis
of "onResourcesLoaded" by 1.5^3=3.3x.

Bug: 145052564
Change-Id: Ib6ab111511d6bd3afae0c29cd00f743e7128768a
Tested: aapt2_tests
This commit is contained in:
Donald Chai
2019-11-25 23:05:51 -08:00
parent 3666704994
commit d520db5355
2 changed files with 14 additions and 7 deletions

View File

@@ -522,9 +522,15 @@ TEST(JavaClassGeneratorTest, GenerateOnResourcesLoadedCallbackForSharedLibrary)
ASSERT_TRUE(generator.Generate("android", &out));
out.Flush();
EXPECT_THAT(output, HasSubstr("void onResourcesLoaded"));
EXPECT_THAT(output, HasSubstr("com.foo.R.onResourcesLoaded"));
EXPECT_THAT(output, HasSubstr("com.boo.R.onResourcesLoaded"));
EXPECT_THAT(output, HasSubstr(
R"( public static void onResourcesLoaded(int p) {
com.foo.R.onResourcesLoaded(p);
com.boo.R.onResourcesLoaded(p);
final int packageIdBits = p << 24;
attr.foo = (attr.foo & 0x00ffffff) | packageIdBits;
id.foo = (id.foo & 0x00ffffff) | packageIdBits;
style.foo = (style.foo & 0x00ffffff) | packageIdBits;
})"));
}
TEST(JavaClassGeneratorTest, OnlyGenerateRText) {