summaryrefslogtreecommitdiffstats
path: root/tools/aapt/ResourceTable.cpp
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2012-11-16 15:58:08 -0800
committerChristopher Tate <ctate@google.com>2012-11-27 18:28:49 -0800
commitd8dde13a63565dcd72bcf03a5088407b737ba793 (patch)
tree671cd9a2e230b1f960e673e8c2c1bbd3b535d9cc /tools/aapt/ResourceTable.cpp
parentaeb6268645d571dfc9f2d387a7ad2471039ddb54 (diff)
downloadframeworks_base-d8dde13a63565dcd72bcf03a5088407b737ba793.zip
frameworks_base-d8dde13a63565dcd72bcf03a5088407b737ba793.tar.gz
frameworks_base-d8dde13a63565dcd72bcf03a5088407b737ba793.tar.bz2
Cache resource ID lookups in aapt
This speeds up certain workloads considerably, particularly those involved in buildling apps via the SDK. Windows-based use should particularly benefit from the change. Change-Id: I29f4b3a77400b201ee219729cc28a5e359c0c5e8
Diffstat (limited to 'tools/aapt/ResourceTable.cpp')
-rw-r--r--tools/aapt/ResourceTable.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 3d7b088..52ebaf0 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -8,6 +8,7 @@
#include "XMLNode.h"
#include "ResourceFilter.h"
+#include "ResourceIdCache.h"
#include <androidfw/ResourceTypes.h>
#include <utils/ByteOrder.h>
@@ -1998,6 +1999,9 @@ uint32_t ResourceTable::getResId(const String16& package,
const String16& name,
bool onlyPublic) const
{
+ uint32_t id = ResourceIdCache::lookup(package, type, name, onlyPublic);
+ if (id != 0) return id; // cache hit
+
sp<Package> p = mPackages.valueFor(package);
if (p == NULL) return 0;
@@ -2016,11 +2020,10 @@ uint32_t ResourceTable::getResId(const String16& package,
}
if (Res_INTERNALID(rid)) {
- return rid;
+ return ResourceIdCache::store(package, type, name, onlyPublic, rid);
}
- return Res_MAKEID(p->getAssignedId()-1,
- Res_GETTYPE(rid),
- Res_GETENTRY(rid));
+ return ResourceIdCache::store(package, type, name, onlyPublic,
+ Res_MAKEID(p->getAssignedId()-1, Res_GETTYPE(rid), Res_GETENTRY(rid)));
}
sp<Type> t = p->getTypes().valueFor(type);
@@ -2029,7 +2032,9 @@ uint32_t ResourceTable::getResId(const String16& package,
if (c == NULL) return 0;
int32_t ei = c->getEntryIndex();
if (ei < 0) return 0;
- return getResId(p, t, ei);
+
+ return ResourceIdCache::store(package, type, name, onlyPublic,
+ getResId(p, t, ei));
}
uint32_t ResourceTable::getResId(const String16& ref,