Ignore:
Timestamp:
Apr 7, 2009, 2:15:33 PM (16 years ago)
Author:
[email protected]
Message:

2009-04-07 David Levin <[email protected]>

Reviewed by Sam Weinig and Geoff Garen.

https://bugs.webkit.org/show_bug.cgi?id=25039
UString refactoring to support UChar* sharing.

No change in sunspider perf.

  • runtime/SmallStrings.cpp: (JSC::SmallStringsStorage::SmallStringsStorage):
  • runtime/UString.cpp: (JSC::initializeStaticBaseString): (JSC::initializeUString): (JSC::UString::BaseString::isShared): Encapsulate the meaning behind the refcount == 1 checks because this needs to do slightly more when sharing is added. (JSC::concatenate): (JSC::UString::append): (JSC::UString::operator=):
  • runtime/UString.h: Make m_baseString part of a union to get rid of casts, but make it protected because it is tricky to use it correctly since it is only valid when the Rep is not a BaseString. The void* will be filled in when sharing is added.

Add constructors due to the making members protected and it make ensuring proper
initialization work better (like in SmallStringsStorage).
(JSC::UString::Rep::create):
(JSC::UString::Rep::Rep):
(JSC::UString::Rep::):
(JSC::UString::BaseString::BaseString):
(JSC::UString::Rep::setBaseString):
(JSC::UString::Rep::baseString):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/SmallStrings.cpp

    r39956 r42282  
    4848
    4949SmallStringsStorage::SmallStringsStorage()
     50    : m_base(m_characters, numCharactersToStore)
    5051{
    51     for (unsigned i = 0; i < numCharactersToStore; ++i)
    52         m_characters[i] = i;
    53 
    5452    m_base.rc = numCharactersToStore + 1;
    55     m_base.buf = m_characters;
    56     m_base.len = numCharactersToStore;
    57     m_base.offset = 0;
    58     m_base._hash = 0;
    59     m_base.m_baseString = 0;
    60     m_base.preCapacity = 0;
    61     m_base.usedPreCapacity = 0;
    62     m_base.reportedCost = 0;
    63 
    6453    // make sure UString doesn't try to reuse the buffer by pretending we have one more character in it
    6554    m_base.usedCapacity = numCharactersToStore + 1;
    6655    m_base.capacity = numCharactersToStore + 1;
    6756    m_base.checkConsistency();
     57
     58    for (unsigned i = 0; i < numCharactersToStore; ++i)
     59        m_characters[i] = i;
    6860
    6961    memset(&m_reps, 0, sizeof(m_reps));
Note: See TracChangeset for help on using the changeset viewer.