⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176293 in webkit


Ignore:
Timestamp:
Nov 18, 2014, 4:17:27 PM (12 years ago)
Author:
Chris Dumez
Message:

Have Vector::capacity() return an unsigned instead of a size_t
https://bugs.webkit.org/show_bug.cgi?id=138842

Reviewed by Andreas Kling.

Source/WebCore:

Update the code base now that Vector::capacity() returns an unsigned
type instead of a size_t.

No new tests, no behavior change.

  • editing/TextIterator.cpp:

(WebCore::SearchBuffer::append):
(WebCore::SearchBuffer::prependContext):
(WebCore::SearchBuffer::search):
(WebCore::SearchBuffer::length):

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::duplicateDataBufferIfNecessary):

Source/WTF:

Have Vector::capacity() return an unsigned instead of a size_t as
capacity is stored as an unsigned internally.

  • wtf/Vector.h:

(WTF::Vector::capacity):
(WTF::OverflowHandler>::expandCapacity):
(WTF::OverflowHandler>::tryExpandCapacity):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r176290 r176293  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Have Vector::capacity() return an unsigned instead of a size_t
     4        https://bugs.webkit.org/show_bug.cgi?id=138842
     5
     6        Reviewed by Andreas Kling.
     7
     8        Have Vector::capacity() return an unsigned instead of a size_t as
     9        capacity is stored as an unsigned internally.
     10
     11        * wtf/Vector.h:
     12        (WTF::Vector::capacity):
     13        (WTF::OverflowHandler>::expandCapacity):
     14        (WTF::OverflowHandler>::tryExpandCapacity):
     15
    1162014-11-18  Geoffrey Garen  <ggaren@apple.com>
    217
  • trunk/Source/WTF/wtf/Vector.h

    r176275 r176293  
    611611    size_t size() const { return m_size; }
    612612    static ptrdiff_t sizeMemoryOffset() { return OBJECT_OFFSETOF(Vector, m_size); }
    613     size_t capacity() const { return Base::capacity(); }
     613    unsigned capacity() const { return Base::capacity(); }
    614614    bool isEmpty() const { return !size(); }
    615615
     
    876876void Vector<T, inlineCapacity, OverflowHandler>::expandCapacity(unsigned newMinCapacity)
    877877{
    878     reserveCapacity(std::max(newMinCapacity, std::max(16u, static_cast<unsigned>(capacity() + capacity() / 4 + 1))));
     878    reserveCapacity(std::max(newMinCapacity, std::max(16u, capacity() + capacity() / 4 + 1)));
    879879}
    880880
     
    894894bool Vector<T, inlineCapacity, OverflowHandler>::tryExpandCapacity(unsigned newMinCapacity)
    895895{
    896     return tryReserveCapacity(std::max(newMinCapacity, std::max(16u, static_cast<unsigned>(capacity() + capacity() / 4 + 1))));
     896    return tryReserveCapacity(std::max(newMinCapacity, std::max(16u, capacity() + capacity() / 4 + 1)));
    897897}
    898898
  • trunk/Source/WebCore/ChangeLog

    r176290 r176293  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Have Vector::capacity() return an unsigned instead of a size_t
     4        https://bugs.webkit.org/show_bug.cgi?id=138842
     5
     6        Reviewed by Andreas Kling.
     7
     8        Update the code base now that Vector::capacity() returns an unsigned
     9        type instead of a size_t.
     10
     11        No new tests, no behavior change.
     12
     13        * editing/TextIterator.cpp:
     14        (WebCore::SearchBuffer::append):
     15        (WebCore::SearchBuffer::prependContext):
     16        (WebCore::SearchBuffer::search):
     17        (WebCore::SearchBuffer::length):
     18        * platform/SharedBuffer.cpp:
     19        (WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
     20
    1212014-11-18  Geoffrey Garen  <ggaren@apple.com>
    222
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r174840 r176293  
    101101
    102102    Vector<UChar> m_buffer;
    103     size_t m_overlap;
    104     size_t m_prefixLength;
     103    unsigned m_overlap;
     104    unsigned m_prefixLength;
    105105    bool m_atBreak;
    106106    bool m_needsMoreContext;
     
    114114private:
    115115    void append(UChar, bool isCharacterStart);
    116     size_t length() const;
     116    unsigned length() const;
    117117
    118118    String m_target;
     
    20112011    } else if (m_buffer.size() == m_buffer.capacity()) {
    20122012        memcpy(m_buffer.data(), m_buffer.data() + m_buffer.size() - m_overlap, m_overlap * sizeof(UChar));
    2013         m_prefixLength -= std::min(m_prefixLength, m_buffer.size() - m_overlap);
     2013        m_prefixLength -= std::min(m_prefixLength, static_cast<unsigned>(m_buffer.size()) - m_overlap);
    20142014        m_buffer.shrink(m_overlap);
    20152015    }
    20162016
    2017     size_t oldLength = m_buffer.size();
    2018     size_t usableLength = std::min<size_t>(m_buffer.capacity() - oldLength, text.length());
     2017    unsigned oldLength = m_buffer.size();
     2018    unsigned usableLength = std::min(m_buffer.capacity() - oldLength, text.length());
    20192019    ASSERT(usableLength);
    20202020    m_buffer.grow(oldLength + usableLength);
     
    20392039    m_atBreak = false;
    20402040
    2041     size_t wordBoundaryContextStart = text.length();
     2041    unsigned wordBoundaryContextStart = text.length();
    20422042    if (wordBoundaryContextStart) {
    20432043        U16_BACK_1(text, 0, wordBoundaryContextStart);
     
    20452045    }
    20462046
    2047     size_t usableLength = std::min(m_buffer.capacity() - m_prefixLength, text.length() - wordBoundaryContextStart);
     2047    unsigned usableLength = std::min(m_buffer.capacity() - m_prefixLength, text.length() - wordBoundaryContextStart);
    20482048    WTF::append(m_buffer, text.substring(text.length() - usableLength, usableLength));
    20492049    m_prefixLength += usableLength;
     
    21912191inline size_t SearchBuffer::search(size_t& start)
    21922192{
    2193     size_t size = m_buffer.size();
     2193    unsigned size = m_buffer.size();
    21942194    if (m_atBreak) {
    21952195        if (!size)
     
    22222222    // possibly including a combining character that's not yet in the buffer.
    22232223    if (!m_atBreak && static_cast<size_t>(matchStart) >= size - m_overlap) {
    2224         size_t overlap = m_overlap;
     2224        unsigned overlap = m_overlap;
    22252225        if (m_options & AtWordStarts) {
    22262226            // Ensure that there is sufficient context before matchStart the next time around for
     
    23592359// That's not necessarily the same length as the passed-in target string, because case folding
    23602360// can make two strings match even though they're not the same length.
    2361 size_t SearchBuffer::length() const
    2362 {
    2363     size_t bufferSize = m_target.length();
    2364     size_t length = 0;
    2365     for (size_t i = 0; i < bufferSize; ++i)
     2361unsigned SearchBuffer::length() const
     2362{
     2363    unsigned bufferSize = m_target.length();
     2364    unsigned length = 0;
     2365    for (unsigned i = 0; i < bufferSize; ++i)
    23662366        length += m_isCharacterStartBuffer[i];
    23672367    return length;
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r175549 r176293  
    253253void SharedBuffer::duplicateDataBufferIfNecessary() const
    254254{
    255     size_t currentCapacity = m_buffer->data.capacity();
     255    unsigned currentCapacity = m_buffer->data.capacity();
    256256    if (m_buffer->hasOneRef() || m_size <= currentCapacity)
    257257        return;
    258258
    259     size_t newCapacity = std::max(static_cast<size_t>(m_size), currentCapacity * 2);
     259    unsigned newCapacity = std::max(m_size, currentCapacity * 2);
    260260    RefPtr<DataBuffer> newBuffer = adoptRef(new DataBuffer);
    261261    newBuffer->data.reserveInitialCapacity(newCapacity);
Note: See TracChangeset for help on using the changeset viewer.