- Revision
- 176293
- Author
- [email protected]
- Date
- 2014-11-18 16:17:27 -0800 (Tue, 18 Nov 2014)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (176292 => 176293)
--- trunk/Source/WTF/ChangeLog 2014-11-18 23:07:30 UTC (rev 176292)
+++ trunk/Source/WTF/ChangeLog 2014-11-19 00:17:27 UTC (rev 176293)
@@ -1,3 +1,18 @@
+2014-11-18 Chris Dumez <[email protected]>
+
+ Have Vector::capacity() return an unsigned instead of a size_t
+ https://bugs.webkit.org/show_bug.cgi?id=138842
+
+ Reviewed by Andreas Kling.
+
+ 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):
+
2014-11-18 Geoffrey Garen <[email protected]>
Removed the custom allocator for ListHashSet nodes
Modified: trunk/Source/WTF/wtf/Vector.h (176292 => 176293)
--- trunk/Source/WTF/wtf/Vector.h 2014-11-18 23:07:30 UTC (rev 176292)
+++ trunk/Source/WTF/wtf/Vector.h 2014-11-19 00:17:27 UTC (rev 176293)
@@ -610,7 +610,7 @@
size_t size() const { return m_size; }
static ptrdiff_t sizeMemoryOffset() { return OBJECT_OFFSETOF(Vector, m_size); }
- size_t capacity() const { return Base::capacity(); }
+ unsigned capacity() const { return Base::capacity(); }
bool isEmpty() const { return !size(); }
T& at(unsigned i)
@@ -875,7 +875,7 @@
template<typename T, unsigned inlineCapacity, typename OverflowHandler>
void Vector<T, inlineCapacity, OverflowHandler>::expandCapacity(unsigned newMinCapacity)
{
- reserveCapacity(std::max(newMinCapacity, std::max(16u, static_cast<unsigned>(capacity() + capacity() / 4 + 1))));
+ reserveCapacity(std::max(newMinCapacity, std::max(16u, capacity() + capacity() / 4 + 1)));
}
template<typename T, unsigned inlineCapacity, typename OverflowHandler>
@@ -893,7 +893,7 @@
template<typename T, unsigned inlineCapacity, typename OverflowHandler>
bool Vector<T, inlineCapacity, OverflowHandler>::tryExpandCapacity(unsigned newMinCapacity)
{
- return tryReserveCapacity(std::max(newMinCapacity, std::max(16u, static_cast<unsigned>(capacity() + capacity() / 4 + 1))));
+ return tryReserveCapacity(std::max(newMinCapacity, std::max(16u, capacity() + capacity() / 4 + 1)));
}
template<typename T, unsigned inlineCapacity, typename OverflowHandler>
Modified: trunk/Source/WebCore/ChangeLog (176292 => 176293)
--- trunk/Source/WebCore/ChangeLog 2014-11-18 23:07:30 UTC (rev 176292)
+++ trunk/Source/WebCore/ChangeLog 2014-11-19 00:17:27 UTC (rev 176293)
@@ -1,3 +1,23 @@
+2014-11-18 Chris Dumez <[email protected]>
+
+ Have Vector::capacity() return an unsigned instead of a size_t
+ https://bugs.webkit.org/show_bug.cgi?id=138842
+
+ Reviewed by Andreas Kling.
+
+ 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):
+
2014-11-18 Geoffrey Garen <[email protected]>
Removed the custom allocator for ListHashSet nodes
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (176292 => 176293)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2014-11-18 23:07:30 UTC (rev 176292)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2014-11-19 00:17:27 UTC (rev 176293)
@@ -100,8 +100,8 @@
FindOptions m_options;
Vector<UChar> m_buffer;
- size_t m_overlap;
- size_t m_prefixLength;
+ unsigned m_overlap;
+ unsigned m_prefixLength;
bool m_atBreak;
bool m_needsMoreContext;
@@ -113,7 +113,7 @@
private:
void append(UChar, bool isCharacterStart);
- size_t length() const;
+ unsigned length() const;
String m_target;
FindOptions m_options;
@@ -2010,12 +2010,12 @@
m_atBreak = false;
} else if (m_buffer.size() == m_buffer.capacity()) {
memcpy(m_buffer.data(), m_buffer.data() + m_buffer.size() - m_overlap, m_overlap * sizeof(UChar));
- m_prefixLength -= std::min(m_prefixLength, m_buffer.size() - m_overlap);
+ m_prefixLength -= std::min(m_prefixLength, static_cast<unsigned>(m_buffer.size()) - m_overlap);
m_buffer.shrink(m_overlap);
}
- size_t oldLength = m_buffer.size();
- size_t usableLength = std::min<size_t>(m_buffer.capacity() - oldLength, text.length());
+ unsigned oldLength = m_buffer.size();
+ unsigned usableLength = std::min(m_buffer.capacity() - oldLength, text.length());
ASSERT(usableLength);
m_buffer.grow(oldLength + usableLength);
for (unsigned i = 0; i < usableLength; ++i)
@@ -2038,13 +2038,13 @@
m_atBreak = false;
- size_t wordBoundaryContextStart = text.length();
+ unsigned wordBoundaryContextStart = text.length();
if (wordBoundaryContextStart) {
U16_BACK_1(text, 0, wordBoundaryContextStart);
wordBoundaryContextStart = startOfLastWordBoundaryContext(text.substring(0, wordBoundaryContextStart));
}
- size_t usableLength = std::min(m_buffer.capacity() - m_prefixLength, text.length() - wordBoundaryContextStart);
+ unsigned usableLength = std::min(m_buffer.capacity() - m_prefixLength, text.length() - wordBoundaryContextStart);
WTF::append(m_buffer, text.substring(text.length() - usableLength, usableLength));
m_prefixLength += usableLength;
@@ -2190,7 +2190,7 @@
inline size_t SearchBuffer::search(size_t& start)
{
- size_t size = m_buffer.size();
+ unsigned size = m_buffer.size();
if (m_atBreak) {
if (!size)
return 0;
@@ -2221,7 +2221,7 @@
// The same match may appear later, matching more characters,
// possibly including a combining character that's not yet in the buffer.
if (!m_atBreak && static_cast<size_t>(matchStart) >= size - m_overlap) {
- size_t overlap = m_overlap;
+ unsigned overlap = m_overlap;
if (m_options & AtWordStarts) {
// Ensure that there is sufficient context before matchStart the next time around for
// determining if it is at a word boundary.
@@ -2358,11 +2358,11 @@
// Returns the number of characters that were appended to the buffer (what we are searching in).
// That's not necessarily the same length as the passed-in target string, because case folding
// can make two strings match even though they're not the same length.
-size_t SearchBuffer::length() const
+unsigned SearchBuffer::length() const
{
- size_t bufferSize = m_target.length();
- size_t length = 0;
- for (size_t i = 0; i < bufferSize; ++i)
+ unsigned bufferSize = m_target.length();
+ unsigned length = 0;
+ for (unsigned i = 0; i < bufferSize; ++i)
length += m_isCharacterStartBuffer[i];
return length;
}
Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (176292 => 176293)
--- trunk/Source/WebCore/platform/SharedBuffer.cpp 2014-11-18 23:07:30 UTC (rev 176292)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp 2014-11-19 00:17:27 UTC (rev 176293)
@@ -252,11 +252,11 @@
void SharedBuffer::duplicateDataBufferIfNecessary() const
{
- size_t currentCapacity = m_buffer->data.capacity();
+ unsigned currentCapacity = m_buffer->data.capacity();
if (m_buffer->hasOneRef() || m_size <= currentCapacity)
return;
- size_t newCapacity = std::max(static_cast<size_t>(m_size), currentCapacity * 2);
+ unsigned newCapacity = std::max(m_size, currentCapacity * 2);
RefPtr<DataBuffer> newBuffer = adoptRef(new DataBuffer);
newBuffer->data.reserveInitialCapacity(newCapacity);
newBuffer->data = ""