@@ -98,39 +98,24 @@ int StringPool::entry::compare(const entry& o) const {
9898 return 0 ;
9999}
100100
101- StringPool::StringPool (bool sorted, bool utf8)
102- : mSorted(sorted), mUTF8(utf8), mValues(- 1 ), mIdents (-1 )
101+ StringPool::StringPool (bool utf8) :
102+ mUTF8(utf8), mValues(-1 )
103103{
104104}
105105
106- ssize_t StringPool::add (const String16& value, bool mergeDuplicates,
107- const String8* configTypeName, const ResTable_config* config)
108- {
109- return add (String16 (), value, mergeDuplicates, configTypeName, config);
110- }
111-
112106ssize_t StringPool::add (const String16& value, const Vector<entry_style_span>& spans,
113107 const String8* configTypeName, const ResTable_config* config)
114108{
115- ssize_t res = add (String16 (), value, false , configTypeName, config);
109+ ssize_t res = add (value, false , configTypeName, config);
116110 if (res >= 0 ) {
117111 addStyleSpans (res, spans);
118112 }
119113 return res;
120114}
121115
122- ssize_t StringPool::add (const String16& ident, const String16& value,
116+ ssize_t StringPool::add (const String16& value,
123117 bool mergeDuplicates, const String8* configTypeName, const ResTable_config* config)
124118{
125- if (ident.size () > 0 ) {
126- ssize_t idx = mIdents .valueFor (ident);
127- if (idx >= 0 ) {
128- fprintf (stderr, " ERROR: Duplicate string identifier %s\n " ,
129- String8 (mEntries [idx].value ).string ());
130- return UNKNOWN_ERROR;
131- }
132- }
133-
134119 ssize_t vidx = mValues .indexOfKey (value);
135120 ssize_t pos = vidx >= 0 ? mValues .valueAt (vidx) : -1 ;
136121 ssize_t eidx = pos >= 0 ? mEntryArray .itemAt (pos) : -1 ;
@@ -181,14 +166,8 @@ ssize_t StringPool::add(const String16& ident, const String16& value,
181166 if (first) {
182167 vidx = mValues .add (value, pos);
183168 }
184- if (!mSorted ) {
185- entry& ent = mEntries .editItemAt (eidx);
186- ent.indices .add (pos);
187- }
188- }
189-
190- if (ident.size () > 0 ) {
191- mIdents .add (ident, vidx);
169+ entry& ent = mEntries .editItemAt (eidx);
170+ ent.indices .add (pos);
192171 }
193172
194173 NOISY (printf (" Adding string %s to pool: pos=%d eidx=%d vidx=%d\n " ,
@@ -221,8 +200,6 @@ status_t StringPool::addStyleSpans(size_t idx, const Vector<entry_style_span>& s
221200
222201status_t StringPool::addStyleSpan (size_t idx, const entry_style_span& span)
223202{
224- LOG_ALWAYS_FATAL_IF (mSorted , " Can't use styles with sorted string pools." );
225-
226203 // Place blank entries in the span array up to this index.
227204 while (mEntryStyleArray .size () <= idx) {
228205 mEntryStyleArray .add ();
@@ -234,25 +211,6 @@ status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span)
234211 return NO_ERROR;
235212}
236213
237- size_t StringPool::size () const
238- {
239- return mSorted ? mValues .size () : mEntryArray .size ();
240- }
241-
242- const StringPool::entry& StringPool::entryAt (size_t idx) const
243- {
244- if (!mSorted ) {
245- return mEntries [mEntryArray [idx]];
246- } else {
247- return mEntries [mEntryArray [mValues .valueAt (idx)]];
248- }
249- }
250-
251- size_t StringPool::countIdentifiers () const
252- {
253- return mIdents .size ();
254- }
255-
256214int StringPool::config_sort (const size_t * lhs, const size_t * rhs, void * state)
257215{
258216 StringPool* pool = (StringPool*)state;
@@ -263,8 +221,6 @@ int StringPool::config_sort(const size_t* lhs, const size_t* rhs, void* state)
263221
264222void StringPool::sortByConfig ()
265223{
266- LOG_ALWAYS_FATAL_IF (mSorted , " Can't sort string pool containing identifiers." );
267- LOG_ALWAYS_FATAL_IF (mIdents .size () > 0 , " Can't sort string pool containing identifiers." );
268224 LOG_ALWAYS_FATAL_IF (mOriginalPosToNewPos .size () > 0 , " Can't sort string pool after already sorted." );
269225
270226 const size_t N = mEntryArray .size ();
@@ -432,7 +388,7 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
432388 }
433389 }
434390
435- const size_t ENTRIES = size ();
391+ const size_t ENTRIES = mEntryArray . size ();
436392
437393 // Now build the pool of unique strings.
438394
@@ -566,9 +522,6 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
566522 header->header .size = htodl (pool->getSize ());
567523 header->stringCount = htodl (ENTRIES);
568524 header->styleCount = htodl (STYLES);
569- if (mSorted ) {
570- header->flags |= htodl (ResStringPool_header::SORTED_FLAG);
571- }
572525 if (mUTF8 ) {
573526 header->flags |= htodl (ResStringPool_header::UTF8_FLAG);
574527 }
@@ -578,33 +531,18 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
578531 // Write string index array.
579532
580533 uint32_t * index = (uint32_t *)(header+1 );
581- if (mSorted ) {
582- for (i=0 ; i<ENTRIES; i++) {
583- entry& ent = const_cast <entry&>(entryAt (i));
584- ent.indices .clear ();
585- ent.indices .add (i);
586- *index++ = htodl (ent.offset );
587- }
588- } else {
589- for (i=0 ; i<ENTRIES; i++) {
590- entry& ent = mEntries .editItemAt (mEntryArray [i]);
591- *index++ = htodl (ent.offset );
592- NOISY (printf (" Writing entry #%d: \" %s\" ent=%d off=%d\n " , i,
593- String8 (ent.value ).string (),
594- mEntryArray [i], ent.offset ));
595- }
534+ for (i=0 ; i<ENTRIES; i++) {
535+ entry& ent = mEntries .editItemAt (mEntryArray [i]);
536+ *index++ = htodl (ent.offset );
537+ NOISY (printf (" Writing entry #%d: \" %s\" ent=%d off=%d\n " , i,
538+ String8 (ent.value ).string (),
539+ mEntryArray [i], ent.offset ));
596540 }
597541
598542 // Write style index array.
599543
600- if (mSorted ) {
601- for (i=0 ; i<STYLES; i++) {
602- LOG_ALWAYS_FATAL (" Shouldn't be here!" );
603- }
604- } else {
605- for (i=0 ; i<STYLES; i++) {
606- *index++ = htodl (mEntryStyleArray [i].offset );
607- }
544+ for (i=0 ; i<STYLES; i++) {
545+ *index++ = htodl (mEntryStyleArray [i].offset );
608546 }
609547
610548 return NO_ERROR;
0 commit comments