Log Message
Use prefix form of increment / decrement operators in WTF String classes when possible https://bugs.webkit.org/show_bug.cgi?id=101859
Patch by Christophe Dumez <christophe.du...@intel.com> on 2012-11-13 Reviewed by Benjamin Poulain. Use prefix form of increment / decrement operators whenever possible in WTF String classes as this seems to be the convention in WebKit. * wtf/text/ASCIIFastPath.h: (WTF::copyLCharsFromUCharSource): * wtf/text/AtomicString.cpp: (WTF::AtomicString::add): * wtf/text/Base64.cpp: (WTF::base64Encode): (WTF::base64DecodeInternal): * wtf/text/StringBuilder.cpp: (WTF::StringBuilder::allocateBufferUpConvert): * wtf/text/StringConcatenate.h: * wtf/text/StringImpl.cpp: (WTF::StringImpl::getData16SlowCase): (WTF::StringImpl::upconvertCharacters): (WTF::StringImpl::containsOnlyWhitespace): (WTF::StringImpl::lower): (WTF::StringImpl::upper): (WTF::StringImpl::foldCase): (WTF::StringImpl::stripMatchedCharacters): (WTF::StringImpl::removeCharacters): (WTF::StringImpl::simplifyMatchedCharactersToSpace): (WTF::reverseFindInner): (WTF::reverseFindIgnoringCaseInner): (WTF::StringImpl::replace): (WTF::StringImpl::createWithTerminatingNullCharacter): * wtf/text/StringImpl.h: (WTF::codePointCompare): * wtf/text/WTFString.cpp: (WTF::String::String): (WTF::toIntegralType):
Modified Paths
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/wtf/text/ASCIIFastPath.h
- trunk/Source/WTF/wtf/text/AtomicString.cpp
- trunk/Source/WTF/wtf/text/Base64.cpp
- trunk/Source/WTF/wtf/text/StringBuilder.cpp
- trunk/Source/WTF/wtf/text/StringConcatenate.h
- trunk/Source/WTF/wtf/text/StringImpl.cpp
- trunk/Source/WTF/wtf/text/StringImpl.h
- trunk/Source/WTF/wtf/text/WTFString.cpp
Diff
Modified: trunk/Source/WTF/ChangeLog (134513 => 134514)
--- trunk/Source/WTF/ChangeLog 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/ChangeLog 2012-11-14 01:27:43 UTC (rev 134514)
@@ -1,3 +1,43 @@
+2012-11-13 Christophe Dumez <christophe.du...@intel.com>
+
+ Use prefix form of increment / decrement operators in WTF String classes when possible
+ https://bugs.webkit.org/show_bug.cgi?id=101859
+
+ Reviewed by Benjamin Poulain.
+
+ Use prefix form of increment / decrement operators whenever possible in
+ WTF String classes as this seems to be the convention in WebKit.
+
+ * wtf/text/ASCIIFastPath.h:
+ (WTF::copyLCharsFromUCharSource):
+ * wtf/text/AtomicString.cpp:
+ (WTF::AtomicString::add):
+ * wtf/text/Base64.cpp:
+ (WTF::base64Encode):
+ (WTF::base64DecodeInternal):
+ * wtf/text/StringBuilder.cpp:
+ (WTF::StringBuilder::allocateBufferUpConvert):
+ * wtf/text/StringConcatenate.h:
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::getData16SlowCase):
+ (WTF::StringImpl::upconvertCharacters):
+ (WTF::StringImpl::containsOnlyWhitespace):
+ (WTF::StringImpl::lower):
+ (WTF::StringImpl::upper):
+ (WTF::StringImpl::foldCase):
+ (WTF::StringImpl::stripMatchedCharacters):
+ (WTF::StringImpl::removeCharacters):
+ (WTF::StringImpl::simplifyMatchedCharactersToSpace):
+ (WTF::reverseFindInner):
+ (WTF::reverseFindIgnoringCaseInner):
+ (WTF::StringImpl::replace):
+ (WTF::StringImpl::createWithTerminatingNullCharacter):
+ * wtf/text/StringImpl.h:
+ (WTF::codePointCompare):
+ * wtf/text/WTFString.cpp:
+ (WTF::String::String):
+ (WTF::toIntegralType):
+
2012-11-13 Ryosuke Niwa <rn...@webkit.org>
Build fix after r134490.
Modified: trunk/Source/WTF/wtf/text/ASCIIFastPath.h (134513 => 134514)
--- trunk/Source/WTF/wtf/text/ASCIIFastPath.h 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/ASCIIFastPath.h 2012-11-14 01:27:43 UTC (rev 134514)
@@ -117,7 +117,7 @@
const unsigned endLength = length - ucharsPerLoop + 1;
for (; i < endLength; i += ucharsPerLoop) {
#ifndef NDEBUG
- for (unsigned checkIndex = 0; checkIndex < ucharsPerLoop; checkIndex++)
+ for (unsigned checkIndex = 0; checkIndex < ucharsPerLoop; ++checkIndex)
ASSERT(!(source[i+checkIndex] & 0xff00));
#endif
__m128i first8UChars = _mm_load_si128(reinterpret_cast<const __m128i*>(&source[i]));
Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (134513 => 134514)
--- trunk/Source/WTF/wtf/text/AtomicString.cpp 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp 2012-11-14 01:27:43 UTC (rev 134514)
@@ -267,7 +267,7 @@
unsigned length = 0;
while (s[length] != UChar(0))
- length++;
+ ++length;
if (!length)
return StringImpl::empty();
Modified: trunk/Source/WTF/wtf/text/Base64.cpp (134513 => 134514)
--- trunk/Source/WTF/wtf/text/Base64.cpp 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/Base64.cpp 2012-11-14 01:27:43 UTC (rev 134514)
@@ -124,7 +124,7 @@
// Add padding
while (didx < out.size()) {
out[didx] = '=';
- didx++;
+ ++didx;
}
}
@@ -150,7 +150,7 @@
bool sawEqualsSign = false;
unsigned outLength = 0;
- for (unsigned idx = 0; idx < len; idx++) {
+ for (unsigned idx = 0; idx < len; ++idx) {
unsigned ch = data[idx];
if (ch == '=')
sawEqualsSign = true;
@@ -158,7 +158,7 @@
if (sawEqualsSign)
return false;
out[outLength] = base64DecMap[ch];
- outLength++;
+ ++outLength;
} else if (policy == Base64FailOnInvalidCharacter || (policy == Base64IgnoreWhitespace && !isSpaceOrNewline(ch)))
return false;
}
Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (134513 => 134514)
--- trunk/Source/WTF/wtf/text/StringBuilder.cpp 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp 2012-11-14 01:27:43 UTC (rev 134514)
@@ -124,7 +124,7 @@
ASSERT(m_is8Bit);
// Copy the existing data into a new buffer, set result to point to the end of the existing data.
RefPtr<StringImpl> buffer = StringImpl::createUninitialized(requiredLength, m_bufferCharacters16);
- for (unsigned i = 0; i < m_length; i++)
+ for (unsigned i = 0; i < m_length; ++i)
m_bufferCharacters16[i] = currentCharacters[i];
m_is8Bit = false;
Modified: trunk/Source/WTF/wtf/text/StringConcatenate.h (134513 => 134514)
--- trunk/Source/WTF/wtf/text/StringConcatenate.h 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/StringConcatenate.h 2012-11-14 01:27:43 UTC (rev 134514)
@@ -181,7 +181,7 @@
{
size_t len = 0;
while (m_buffer[len] != UChar(0))
- len++;
+ ++len;
if (len > std::numeric_limits<unsigned>::max())
CRASH();
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (134513 => 134514)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2012-11-14 01:27:43 UTC (rev 134514)
@@ -304,7 +304,7 @@
unsigned len = length();
if (hasTerminatingNullCharacter())
- len++;
+ ++len;
m_copyData16 = static_cast<UChar*>(fastMalloc(len * sizeof(UChar)));
@@ -320,7 +320,7 @@
ASSERT(is8Bit());
ASSERT(has16BitShadow());
- for (size_t i = start; i < end; i++)
+ for (size_t i = start; i < end; ++i)
m_copyData16[i] = m_data8[i];
}
@@ -331,7 +331,7 @@
// that are not whitespace from the point of view of RenderText; I wonder if
// that's a problem in practice.
if (is8Bit()) {
- for (unsigned i = 0; i < m_length; i++) {
+ for (unsigned i = 0; i < m_length; ++i) {
UChar c = m_data8[i];
if (!isASCIISpace(c))
return false;
@@ -340,7 +340,7 @@
return true;
}
- for (unsigned i = 0; i < m_length; i++) {
+ for (unsigned i = 0; i < m_length; ++i) {
UChar c = m_data16[i];
if (!isASCIISpace(c))
return false;
@@ -385,7 +385,7 @@
UChar ored = 0;
if (is8Bit()) {
const LChar* end = m_data8 + m_length;
- for (const LChar* chp = m_data8; chp != end; chp++) {
+ for (const LChar* chp = m_data8; chp != end; ++chp) {
if (UNLIKELY(isASCIIUpper(*chp)))
noUpper = false;
ored |= *chp;
@@ -402,21 +402,21 @@
RefPtr<StringImpl> newImpl = createUninitialized(length, data8);
if (!(ored & ~0x7F)) {
- for (int32_t i = 0; i < length; i++)
+ for (int32_t i = 0; i < length; ++i)
data8[i] = toASCIILower(m_data8[i]);
return newImpl.release();
}
// Do a slower implementation for cases that include non-ASCII Latin-1 characters.
- for (int32_t i = 0; i < length; i++)
+ for (int32_t i = 0; i < length; ++i)
data8[i] = static_cast<LChar>(Unicode::toLower(m_data8[i]));
return newImpl.release();
}
const UChar *end = m_data16 + m_length;
- for (const UChar* chp = m_data16; chp != end; chp++) {
+ for (const UChar* chp = m_data16; chp != end; ++chp) {
if (UNLIKELY(isASCIIUpper(*chp)))
noUpper = false;
ored |= *chp;
@@ -433,7 +433,7 @@
UChar* data16;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
- for (int32_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; ++i) {
UChar c = m_data16[i];
data16[i] = toASCIILower(c);
}
@@ -472,7 +472,7 @@
// Do a faster loop for the case where all the characters are ASCII.
LChar ored = 0;
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < length; ++i) {
LChar c = m_data8[i];
ored |= c;
data8[i] = toASCIIUpper(c);
@@ -486,10 +486,10 @@
// There are two special cases.
// 1. latin-1 characters when converted to upper case are 16 bit characters.
// 2. Lower case sharp-S converts to "SS" (two characters)
- for (int32_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; ++i) {
LChar c = m_data8[i];
if (UNLIKELY(c == smallLetterSharpS))
- numberSharpSCharacters++;
+ ++numberSharpSCharacters;
UChar upper = Unicode::toUpper(c);
if (UNLIKELY(upper > 0xff)) {
// Since this upper-cased character does not fit in an 8-bit string, we need to take the 16-bit path.
@@ -506,7 +506,7 @@
LChar* dest = data8;
- for (int32_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; ++i) {
LChar c = m_data8[i];
if (c == smallLetterSharpS) {
*dest++ = 'S';
@@ -526,7 +526,7 @@
// Do a faster loop for the case where all the characters are ASCII.
UChar ored = 0;
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < length; ++i) {
UChar c = source16[i];
ored |= c;
data16[i] = toASCIIUpper(c);
@@ -578,7 +578,7 @@
RefPtr <StringImpl>newImpl = createUninitialized(m_length, data);
LChar ored = 0;
- for (int32_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; ++i) {
LChar c = m_data8[i];
data[i] = toASCIILower(c);
ored |= c;
@@ -588,7 +588,7 @@
return newImpl.release();
// Do a slower implementation for cases that include non-ASCII Latin-1 characters.
- for (int32_t i = 0; i < length; i++)
+ for (int32_t i = 0; i < length; ++i)
data[i] = static_cast<LChar>(Unicode::toLower(m_data8[i]));
return newImpl.release();
@@ -598,7 +598,7 @@
UChar* data;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data);
UChar ored = 0;
- for (int32_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; ++i) {
UChar c = m_data16[i];
ored |= c;
data[i] = toASCIILower(c);
@@ -629,7 +629,7 @@
// skip white space from start
while (start <= end && predicate(is8Bit() ? m_data8[start] : m_data16[start]))
- start++;
+ ++start;
// only white space
if (start > end)
@@ -637,7 +637,7 @@
// skip white space from end
while (end && predicate(is8Bit() ? m_data8[end] : m_data16[end]))
- end--;
+ --end;
if (!start && end == m_length - 1)
return this;
@@ -685,7 +685,7 @@
// Assume the common case will not remove any characters
while (from != fromend && !findMatch(*from))
- from++;
+ ++from;
if (from == fromend)
return this;
@@ -698,7 +698,7 @@
while (true) {
while (from != fromend && findMatch(*from))
- from++;
+ ++from;
while (from != fromend && !findMatch(*from))
to[outc++] = *from++;
if (from == fromend)
@@ -733,7 +733,7 @@
while (from != fromend && predicate(*from)) {
if (*from != ' ')
changedToSpace = true;
- from++;
+ ++from;
}
while (from != fromend && !predicate(*from))
to[outc++] = *from++;
@@ -744,7 +744,7 @@
}
if (outc > 0 && to[outc - 1] == ' ')
- outc--;
+ --outc;
if (static_cast<unsigned>(outc) == m_length && !changedToSpace)
return this;
@@ -1136,7 +1136,7 @@
while (searchHash != matchHash || !equal(searchCharacters + delta, matchCharacters, matchLength)) {
if (!delta)
return notFound;
- delta--;
+ --delta;
searchHash -= searchCharacters[delta + matchLength];
searchHash += searchCharacters[delta];
}
@@ -1186,7 +1186,7 @@
while (!equalIgnoringCase(searchCharacters + delta, matchCharacters, matchLength)) {
if (!delta)
return notFound;
- delta--;
+ --delta;
}
return delta;
}
@@ -1357,19 +1357,19 @@
RefPtr<StringImpl> newImpl =
createUninitialized(length() - lengthToReplace + lengthToInsert, data);
if (is8Bit())
- for (unsigned i = 0; i < position; i++)
+ for (unsigned i = 0; i < position; ++i)
data[i] = m_data8[i];
else
memcpy(data, m_data16, position * sizeof(UChar));
if (str) {
if (str->is8Bit())
- for (unsigned i = 0; i < lengthToInsert; i++)
+ for (unsigned i = 0; i < lengthToInsert; ++i)
data[i + position] = str->m_data8[i];
else
memcpy(data + position, str->m_data16, lengthToInsert * sizeof(UChar));
}
if (is8Bit()) {
- for (unsigned i = 0; i < length() - position - lengthToReplace; i++)
+ for (unsigned i = 0; i < length() - position - lengthToReplace; ++i)
data[i + position + lengthToInsert] = m_data8[i + position + lengthToReplace];
} else {
memcpy(data + position + lengthToInsert, characters() + position + lengthToReplace,
@@ -1619,7 +1619,7 @@
srcSegmentLength = srcSegmentEnd - srcSegmentStart;
if (srcIs8Bit) {
// Case 3.
- for (unsigned i = 0; i < srcSegmentLength; i++)
+ for (unsigned i = 0; i < srcSegmentLength; ++i)
data[i + dstOffset] = m_data8[i + srcSegmentStart];
} else {
// Case 2 & 4.
@@ -1628,7 +1628,7 @@
dstOffset += srcSegmentLength;
if (replacementIs8Bit) {
// Cases 2 & 3.
- for (unsigned i = 0; i < repStrLength; i++)
+ for (unsigned i = 0; i < repStrLength; ++i)
data[i + dstOffset] = replacement->m_data8[i];
} else {
// Case 4
@@ -1641,7 +1641,7 @@
srcSegmentLength = m_length - srcSegmentStart;
if (srcIs8Bit) {
// Case 3.
- for (unsigned i = 0; i < srcSegmentLength; i++)
+ for (unsigned i = 0; i < srcSegmentLength; ++i)
data[i + dstOffset] = m_data8[i + srcSegmentStart];
} else {
// Cases 2 & 4.
@@ -1860,7 +1860,7 @@
memcpy(data, string.m_data16, length * sizeof(UChar));
data[length] = 0;
}
- terminatedString->m_length--;
+ --(terminatedString->m_length);
terminatedString->m_hashAndFlags = (string.m_hashAndFlags & (~s_flagMask | s_hashFlag8BitBuffer)) | s_hashFlagHasTerminatingNullCharacter;
return terminatedString.release();
}
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (134513 => 134514)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2012-11-14 01:27:43 UTC (rev 134514)
@@ -1068,9 +1068,9 @@
const unsigned lmin = l1 < l2 ? l1 : l2;
unsigned pos = 0;
while (pos < lmin && *c1 == *c2) {
- c1++;
- c2++;
- pos++;
+ ++c1;
+ ++c2;
+ ++pos;
}
if (pos < lmin)
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (134513 => 134514)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2012-11-14 01:18:39 UTC (rev 134513)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2012-11-14 01:27:43 UTC (rev 134514)
@@ -57,7 +57,7 @@
size_t len = 0;
while (str[len] != UChar(0))
- len++;
+ ++len;
if (len > numeric_limits<unsigned>::max())
CRASH();
@@ -936,24 +936,24 @@
// skip leading whitespace
while (length && isSpaceOrNewline(*data)) {
- length--;
- data++;
+ --length;
+ ++data;
}
if (isSigned && length && *data == '-') {
- length--;
- data++;
+ --length;
+ ++data;
isNegative = true;
} else if (length && *data == '+') {
- length--;
- data++;
+ --length;
+ ++data;
}
if (!length || !isCharacterAllowedInBase(*data, base))
goto bye;
while (length && isCharacterAllowedInBase(*data, base)) {
- length--;
+ --length;
IntegralType digitValue;
CharType c = *data;
if (isASCIIDigit(c))
@@ -967,7 +967,7 @@
goto bye;
value = base * value + digitValue;
- data++;
+ ++data;
}
#if COMPILER(MSVC)
@@ -984,8 +984,8 @@
// skip trailing space
while (length && isSpaceOrNewline(*data)) {
- length--;
- data++;
+ --length;
+ ++data;
}
if (!length)
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-changes