- for (unsigned i = 0; i < numCharactersToStore; ++i)
- m_characters[i] = i;
-
- m_base.rc = numCharactersToStore + 1;
- m_base.buf = m_characters;
- m_base.len = numCharactersToStore;
- m_base.offset = 0;
- m_base._hash = 0;
- m_base.m_baseString = 0;
- m_base.preCapacity = 0;
- m_base.usedPreCapacity = 0;
- m_base.reportedCost = 0;
-
- // make sure UString doesn't try to reuse the buffer by pretending we have one more character in it
- m_base.usedCapacity = numCharactersToStore + 1;
- m_base.capacity = numCharactersToStore + 1;
- m_base.checkConsistency();
-
- memset(&m_reps, 0, sizeof(m_reps));
- for (unsigned i = 0; i < numCharactersToStore; ++i) {
- m_reps[i].offset = i;
- m_reps[i].len = 1;
- m_reps[i].rc = 1;
- m_reps[i].setBaseString(&m_base);
- m_reps[i].checkConsistency();
+ LChar* characterBuffer = 0;
+ RefPtr<StringImpl> baseString = StringImpl::createUninitialized(singleCharacterStringCount, characterBuffer);
+ for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
+ characterBuffer[i] = i;
+ m_reps[i] = AtomicString::add(PassRefPtr<StringImpl>(StringImpl::createSubstringSharingImpl(baseString, i, 1)).get());