Revert "Use reference counted pointers for ApkAssets"
This reverts commit c357f719ed3734aee05418808699a48dd150a1a5.
Reason for revert: b/279154343 - performance regression
Change-Id: If2e212d8fc5b9ed8638032a33f450440cbaeceb0
diff --git a/libs/androidfw/tests/AssetManager2_bench.cpp b/libs/androidfw/tests/AssetManager2_bench.cpp
index 6fae72a..c7ae618 100644
--- a/libs/androidfw/tests/AssetManager2_bench.cpp
+++ b/libs/androidfw/tests/AssetManager2_bench.cpp
@@ -38,9 +38,9 @@
static void BM_AssetManagerLoadAssets(benchmark::State& state) {
std::string path = GetTestDataPath() + "/basic/basic.apk";
while (state.KeepRunning()) {
- auto apk = ApkAssets::Load(path);
+ std::unique_ptr<const ApkAssets> apk = ApkAssets::Load(path);
AssetManager2 assets;
- assets.SetApkAssets({apk});
+ assets.SetApkAssets({apk.get()});
}
}
BENCHMARK(BM_AssetManagerLoadAssets);
@@ -61,9 +61,9 @@
static void BM_AssetManagerLoadFrameworkAssets(benchmark::State& state) {
std::string path = kFrameworkPath;
while (state.KeepRunning()) {
- auto apk = ApkAssets::Load(path);
+ std::unique_ptr<const ApkAssets> apk = ApkAssets::Load(path);
AssetManager2 assets;
- assets.SetApkAssets({apk});
+ assets.SetApkAssets({apk.get()});
}
}
BENCHMARK(BM_AssetManagerLoadFrameworkAssets);
@@ -129,14 +129,14 @@
BENCHMARK(BM_AssetManagerGetResourceFrameworkLocaleOld);
static void BM_AssetManagerGetBag(benchmark::State& state) {
- auto apk = ApkAssets::Load(GetTestDataPath() + "/styles/styles.apk");
+ std::unique_ptr<const ApkAssets> apk = ApkAssets::Load(GetTestDataPath() + "/styles/styles.apk");
if (apk == nullptr) {
state.SkipWithError("Failed to load assets");
return;
}
AssetManager2 assets;
- assets.SetApkAssets({apk});
+ assets.SetApkAssets({apk.get()});
while (state.KeepRunning()) {
auto bag = assets.GetBag(app::R::style::StyleTwo);
@@ -181,14 +181,14 @@
BENCHMARK(BM_AssetManagerGetBagOld);
static void BM_AssetManagerGetResourceLocales(benchmark::State& state) {
- auto apk = ApkAssets::Load(kFrameworkPath);
+ std::unique_ptr<const ApkAssets> apk = ApkAssets::Load(kFrameworkPath);
if (apk == nullptr) {
state.SkipWithError("Failed to load assets");
return;
}
AssetManager2 assets;
- assets.SetApkAssets({apk});
+ assets.SetApkAssets({apk.get()});
while (state.KeepRunning()) {
std::set<std::string> locales =
@@ -217,14 +217,14 @@
BENCHMARK(BM_AssetManagerGetResourceLocalesOld);
static void BM_AssetManagerSetConfigurationFramework(benchmark::State& state) {
- auto apk = ApkAssets::Load(kFrameworkPath);
+ std::unique_ptr<const ApkAssets> apk = ApkAssets::Load(kFrameworkPath);
if (apk == nullptr) {
state.SkipWithError("Failed to load assets");
return;
}
AssetManager2 assets;
- assets.SetApkAssets({apk});
+ assets.SetApkAssets({apk.get()});
ResTable_config config;
memset(&config, 0, sizeof(config));