Changeset 30593 in webkit for trunk/JavaScriptCore/wtf/Vector.h


Ignore:
Timestamp:
Feb 26, 2008, 9:06:24 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Dan Bernstein.

  • Add a variant of remove that takes a position and a length.
  • wtf/Vector.h: (WTF::Vector::remove):

WebCore:

Reviewed by Dan Bernstein.

Make the cleanPath function in CSSStyleSelector more efficient by using
a Vector<UChar>.

  • css/CSSStyleSelector.cpp: (WebCore::cleanPath): Make this function work on a Vector<UChar> instead of a String. Also remove unnecessary reverseFind call that could be acomplished with two compares. (WebCore::checkPseudoState): Remove reserveCapacity calls now that we are using a stack buffer.
  • platform/text/PlatformString.h: (WebCore::find): Make this find generic enough that it can be used for String::find. (WebCore::reverseFind): Implement reverseFind so that it can be used for with a UChar* and length.
  • platform/text/StringImpl.cpp: (WebCore::StringImpl::find): Use implementation in PlatformString.cpp (WebCore::StringImpl::reverseFind): Ditto,
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Vector.h

    r30538 r30593  
    473473
    474474        void remove(size_t position);
     475        void remove(size_t position, size_t length);
    475476
    476477        void removeLast()
     
    776777
    777778    template<typename T, size_t inlineCapacity>
     779    inline void Vector<T, inlineCapacity>::remove(size_t position, size_t length)
     780    {
     781        ASSERT(position < size());
     782        ASSERT(position + length < size());
     783        T* beginSpot = begin() + position;
     784        T* endSpot = beginSpot + length;
     785        TypeOperations::destruct(beginSpot, endSpot);
     786        TypeOperations::moveOverlapping(endSpot, end(), beginSpot);
     787        m_size -= length;
     788    }
     789
     790    template<typename T, size_t inlineCapacity>
    778791    inline T* Vector<T, inlineCapacity>::releaseBuffer()
    779792    {
Note: See TracChangeset for help on using the changeset viewer.