diff options
author | Kenny Root <kroot@google.com> | 2010-02-22 22:36:26 -0800 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2010-02-23 10:02:20 -0800 |
commit | 780d2a1b714724d85227141c76b3c64f543f00b4 (patch) | |
tree | 3bd5411acce1ae663e4509c812b3aaa6100c6a41 /tools | |
parent | cfe79e9220c996ed9f60fbc00eebb23e7faba2f0 (diff) | |
download | frameworks_base-780d2a1b714724d85227141c76b3c64f543f00b4.zip frameworks_base-780d2a1b714724d85227141c76b3c64f543f00b4.tar.gz frameworks_base-780d2a1b714724d85227141c76b3c64f543f00b4.tar.bz2 |
Use UTF-8 strings to avoid duplicate caching, part 1
StringBlock instances containing UTF-8 strings use a cache to convert
into UTF-16, but using that cache and then using a JNI call to NewString
causes the UTF-8 string as well as two copies of the UTF-16 string to
be held in memory. Getting the UTF-8 string directly from the StringPool
eliminates one copy of the UTF-16 string being held in memory.
This is part 1. Part 2 will include ResXMLParser optimizations.
Change-Id: Ibd4509a485db746d59cd4b9501f544877139276c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aapt/StringPool.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp index 51afc0a..a09cec0 100644 --- a/tools/aapt/StringPool.cpp +++ b/tools/aapt/StringPool.cpp @@ -25,8 +25,12 @@ void printStringPool(const ResStringPool* pool) const size_t NS = pool->size(); for (size_t s=0; s<NS; s++) { size_t len; - printf("String #%ld: %s\n", s, - String8(pool->stringAt(s, &len)).string()); + const char *str = (const char*)pool->string8At(s, &len); + if (str == NULL) { + str = String8(pool->stringAt(s, &len)).string(); + } + + printf("String #%ld: %s\n", s, str); } } |