summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager2.cpp
diff options
context:
space:
mode:
author Yurii Zubrytskyi <zyy@google.com> 2025-03-20 12:17:05 -0700
committer Yurii Zubrytskyi <zyy@google.com> 2025-03-20 22:38:25 -0700
commit984a84eed846b5c04265057075d574b440564168 (patch)
tree347bc58ec194f0670dbf5f6612079fc8f4fa9b99 /libs/androidfw/AssetManager2.cpp
parentc74a0961123efd89b350476e6d7a49b623e1d798 (diff)
[res] A bit more efficient locale collection
Don't copy the string unless it's a new locale, and limit the allocations as well Test: unit tests Flag: EXEMPT minor performance improvement Change-Id: Icfe433ab211a0ca22882bd579415a96dc40db30a
Diffstat (limited to 'libs/androidfw/AssetManager2.cpp')
-rw-r--r--libs/androidfw/AssetManager2.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index e09ab5fd1643..f169cfa68946 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -600,12 +600,12 @@ base::expected<std::set<ResTable_config>, IOError> AssetManager2::GetResourceCon
return configurations;
}
-std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system,
- bool merge_equivalent_languages) const {
+LoadedPackage::Locales AssetManager2::GetResourceLocales(
+ bool exclude_system, bool merge_equivalent_languages) const {
ATRACE_NAME("AssetManager::GetResourceLocales");
auto op = StartOperation();
- std::set<std::string> locales;
+ LoadedPackage::Locales locales;
const auto non_system_overlays =
exclude_system ? GetNonSystemOverlays() : std::set<ApkAssetsPtr>();
@@ -619,8 +619,7 @@ std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system,
if (!non_system_overlays.empty()) {
// Exclude overlays that target only system resources.
const auto& apk_assets = GetApkAssets(package_group.cookies_[i]);
- if (apk_assets && apk_assets->IsOverlay() &&
- non_system_overlays.find(apk_assets) == non_system_overlays.end()) {
+ if (apk_assets && apk_assets->IsOverlay() && !non_system_overlays.contains(apk_assets)) {
continue;
}
}