Ignore:
Timestamp:
Mar 11, 2010, 7:14:17 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=36041
Remove unnecessary differences in common code between WebCore::StringImpl & JSC::UStringImpl

Reviewed by Oliver Hunt.

Much of the code in WebCore::StringImpl and JSC::UStringImpl is now very similar,
but has trivial and unnecessary formatting differences, such as the exact wording
of comments, missing ASSERTs, functions implemented in the .h vs .cpp etc.

JavaScriptCore:

  • runtime/Identifier.cpp:

(JSC::Identifier::add): UStringImpl::empty() now automatically hashes, uas per WebCore strings.
(JSC::Identifier::addSlowCase): UStringImpl::empty() now automatically hashes, uas per WebCore strings.

  • runtime/UStringImpl.cpp:

(JSC::UStringImpl::~UStringImpl): Only call bufferOwnership() once, add missing ASSERTs.
(JSC::UStringImpl::createUninitialized): Move from .h, not commonly called, no need to inline.
(JSC::UStringImpl::create): Move from .h, not commonly called, no need to inline.
(JSC::UStringImpl::sharedBuffer): Rewritten to more closely match WebCore implementation, remove need for separate baseSharedBuffer() method.

  • runtime/UStringImpl.h:

(JSC::UStringImpl::UStringImpl): Automatically hash static strings, ASSERT m_data & m_length are non-null/non-zero in non-static strings.
(JSC::UStringImpl::setHash): Add missing ASSERT.
(JSC::UStringImpl::create): Moved to .cpp / added missing check for empty string creation.
(JSC::UStringImpl::adopt): Vector.size() returns size_t, not unsigned.
(JSC::UStringImpl::cost): Renamed m_bufferSubstring -> m_substringBuffer
(JSC::UStringImpl::hash): Reordered in file.
(JSC::UStringImpl::existingHash): Reordered in file.
(JSC::UStringImpl::computeHash): Reordered in file, renamed parameter.
(JSC::UStringImpl::checkConsistency): rewrote ASSERT.
(JSC::UStringImpl::bufferOwnership): Return type should be BufferOwnership.
(JSC::UStringImpl::): Moved friends to head of class.

WebCore:

  • platform/text/StringImpl.cpp:

(WebCore::StringImpl::empty): Reordered in file, made empty()->characters() return a non-null value to match JSC.
(WebCore::StringImpl::createUninitialized): Added overflow check.
(WebCore::StringImpl::create): Reordered in file.
(WebCore::StringImpl::sharedBuffer): Reordered in file.

  • platform/text/StringImpl.h:

(WebCore::StringImpl::): Remove ThreadGlobalData as friend, move SharableUChar & SharedUChar to WebCore namespace.
(WebCore::StringImpl::StringImpl): Made static constructor method (used to create empty string) take arguments, to match JSC & prevent accidental use.
(WebCore::StringImpl::setHash): Added missing ASSERT.
(WebCore::StringImpl::adopt): Make adpot work with Vectors with a non-zero inline capacity.
(WebCore::StringImpl::characters): Mark as const to match JSC.
(WebCore::StringImpl::hash): Use !m_hash instead of m_hash == 0.
(WebCore::StringImpl::computeHash): Remove redundant 'inline'.

File:
1 edited

Legend:

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

    r55833 r55878  
    4444            (*iter)->setIsIdentifier(false);
    4545    }
    46    
     46
    4747    std::pair<HashSet<UString::Rep*>::iterator, bool> add(UString::Rep* value)
    4848    {
     
    130130        return rep;
    131131    }
    132     if (!c[0]) {
    133         UString::Rep::empty()->hash();
     132    if (!c[0])
    134133        return UString::Rep::empty();
    135     }
    136134    if (!c[1])
    137135        return add(globalData, globalData->smallStrings.singleCharacterStringRep(static_cast<unsigned char>(c[0])));
     
    194192            return add(globalData, globalData->smallStrings.singleCharacterStringRep(c));
    195193    }
    196     if (!length) {
    197         UString::Rep::empty()->hash();
     194    if (!length)
    198195        return UString::Rep::empty();
    199     }
    200196    UCharBuffer buf = {s, length};
    201197    pair<HashSet<UString::Rep*>::iterator, bool> addResult = globalData->identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf);
     
    225221            }
    226222    }
    227     if (!r->length()) {
    228         UString::Rep::empty()->hash();
     223    if (!r->length())
    229224        return UString::Rep::empty();
    230     }
    231225    return *globalData->identifierTable->add(r).first;
    232226}
Note: See TracChangeset for help on using the changeset viewer.