Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringImpl.cpp

Issue 1859513002: Revert of Replace all occurrences of RELEASE_ASSERT in wtf with CHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [rebase: remove BitArray.h diff] Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 4 * (C) 2001 Dirk Mueller ( mueller@kde.org )
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 StaticStringsTable::const_iterator it = staticStrings().find(hash); 351 StaticStringsTable::const_iterator it = staticStrings().find(hash);
352 if (it != staticStrings().end()) { 352 if (it != staticStrings().end()) {
353 ASSERT(!memcmp(string, it->value + 1, length * sizeof(LChar))); 353 ASSERT(!memcmp(string, it->value + 1, length * sizeof(LChar)));
354 return it->value; 354 return it->value;
355 } 355 }
356 356
357 // Allocate a single buffer large enough to contain the StringImpl 357 // Allocate a single buffer large enough to contain the StringImpl
358 // struct as well as the data which it contains. This removes one 358 // struct as well as the data which it contains. This removes one
359 // heap allocation from this call. 359 // heap allocation from this call.
360 CHECK_LE(length, (std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(LChar)); 360 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str ingImpl)) / sizeof(LChar)));
361 size_t size = sizeof(StringImpl) + length * sizeof(LChar); 361 size_t size = sizeof(StringImpl) + length * sizeof(LChar);
362 362
363 WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE; 363 WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE;
364 StringImpl* impl = static_cast<StringImpl*>(Partitions::bufferMalloc(size, " WTF::StringImpl")); 364 StringImpl* impl = static_cast<StringImpl*>(Partitions::bufferMalloc(size, " WTF::StringImpl"));
365 365
366 LChar* data = reinterpret_cast<LChar*>(impl + 1); 366 LChar* data = reinterpret_cast<LChar*>(impl + 1);
367 impl = new (impl) StringImpl(length, hash, StaticString); 367 impl = new (impl) StringImpl(length, hash, StaticString);
368 memcpy(data, string, length * sizeof(LChar)); 368 memcpy(data, string, length * sizeof(LChar));
369 #if ENABLE(ASSERT) 369 #if ENABLE(ASSERT)
370 impl->assertHashIsCorrect(); 370 impl->assertHashIsCorrect();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 423
424 return string.release(); 424 return string.release();
425 } 425 }
426 426
427 PassRefPtr<StringImpl> StringImpl::create(const LChar* string) 427 PassRefPtr<StringImpl> StringImpl::create(const LChar* string)
428 { 428 {
429 if (!string) 429 if (!string)
430 return empty(); 430 return empty();
431 size_t length = strlen(reinterpret_cast<const char*>(string)); 431 size_t length = strlen(reinterpret_cast<const char*>(string));
432 CHECK_LE(length, numeric_limits<unsigned>::max()); 432 RELEASE_ASSERT(length <= numeric_limits<unsigned>::max());
433 return create(string, length); 433 return create(string, length);
434 } 434 }
435 435
436 bool StringImpl::containsOnlyWhitespace() 436 bool StringImpl::containsOnlyWhitespace()
437 { 437 {
438 // FIXME: The definition of whitespace here includes a number of characters 438 // FIXME: The definition of whitespace here includes a number of characters
439 // that are not whitespace from the point of view of LayoutText; I wonder if 439 // that are not whitespace from the point of view of LayoutText; I wonder if
440 // that's a problem in practice. 440 // that's a problem in practice.
441 if (is8Bit()) { 441 if (is8Bit()) {
442 for (unsigned i = 0; i < m_length; ++i) { 442 for (unsigned i = 0; i < m_length; ++i) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 const UChar* end = characters16() + m_length; 518 const UChar* end = characters16() + m_length;
519 for (const UChar* chp = characters16(); chp != end; ++chp) { 519 for (const UChar* chp = characters16(); chp != end; ++chp) {
520 if (isASCIIUpper(*chp)) 520 if (isASCIIUpper(*chp))
521 noUpper = false; 521 noUpper = false;
522 ored |= *chp; 522 ored |= *chp;
523 } 523 }
524 // Nothing to do if the string is all ASCII with no uppercase. 524 // Nothing to do if the string is all ASCII with no uppercase.
525 if (noUpper && !(ored & ~0x7F)) 525 if (noUpper && !(ored & ~0x7F))
526 return this; 526 return this;
527 527
528 CHECK_LE(m_length, static_cast<unsigned>(numeric_limits<unsigned>::max())); 528 RELEASE_ASSERT(m_length <= static_cast<unsigned>(numeric_limits<unsigned>::m ax()));
529 unsigned length = m_length; 529 unsigned length = m_length;
530 530
531 UChar* data16; 531 UChar* data16;
532 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16); 532 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
533 533
534 for (unsigned i = 0; i < length; ++i) { 534 for (unsigned i = 0; i < length; ++i) {
535 UChar c = characters16()[i]; 535 UChar c = characters16()[i];
536 data16[i] = isASCIIUpper(c) ? toASCIILower(c) : c; 536 data16[i] = isASCIIUpper(c) ? toASCIILower(c) : c;
537 } 537 }
538 return newImpl.release(); 538 return newImpl.release();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 const UChar* end = characters16() + m_length; 577 const UChar* end = characters16() + m_length;
578 for (const UChar* chp = characters16(); chp != end; ++chp) { 578 for (const UChar* chp = characters16(); chp != end; ++chp) {
579 if (UNLIKELY(isASCIIUpper(*chp))) 579 if (UNLIKELY(isASCIIUpper(*chp)))
580 noUpper = false; 580 noUpper = false;
581 ored |= *chp; 581 ored |= *chp;
582 } 582 }
583 // Nothing to do if the string is all ASCII with no uppercase. 583 // Nothing to do if the string is all ASCII with no uppercase.
584 if (noUpper && !(ored & ~0x7F)) 584 if (noUpper && !(ored & ~0x7F))
585 return this; 585 return this;
586 586
587 CHECK_LE(m_length, static_cast<unsigned>(numeric_limits<int32_t>::max())); 587 RELEASE_ASSERT(m_length <= static_cast<unsigned>(numeric_limits<int32_t>::ma x()));
588 int32_t length = m_length; 588 int32_t length = m_length;
589 589
590 if (!(ored & ~0x7F)) { 590 if (!(ored & ~0x7F)) {
591 UChar* data16; 591 UChar* data16;
592 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16); 592 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
593 593
594 for (int32_t i = 0; i < length; ++i) { 594 for (int32_t i = 0; i < length; ++i) {
595 UChar c = characters16()[i]; 595 UChar c = characters16()[i];
596 data16[i] = toASCIILower(c); 596 data16[i] = toASCIILower(c);
597 } 597 }
(...skipping 15 matching lines...) Expand all
613 return this; 613 return this;
614 return newImpl.release(); 614 return newImpl.release();
615 } 615 }
616 616
617 PassRefPtr<StringImpl> StringImpl::upper() 617 PassRefPtr<StringImpl> StringImpl::upper()
618 { 618 {
619 // This function could be optimized for no-op cases the way lower() is, 619 // This function could be optimized for no-op cases the way lower() is,
620 // but in empirical testing, few actual calls to upper() are no-ops, so 620 // but in empirical testing, few actual calls to upper() are no-ops, so
621 // it wouldn't be worth the extra time for pre-scanning. 621 // it wouldn't be worth the extra time for pre-scanning.
622 622
623 CHECK_LE(m_length, static_cast<unsigned>(numeric_limits<int32_t>::max())); 623 RELEASE_ASSERT(m_length <= static_cast<unsigned>(numeric_limits<int32_t>::ma x()));
624 int32_t length = m_length; 624 int32_t length = m_length;
625 625
626 if (is8Bit()) { 626 if (is8Bit()) {
627 LChar* data8; 627 LChar* data8;
628 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8); 628 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8);
629 629
630 // Do a faster loop for the case where all the characters are ASCII. 630 // Do a faster loop for the case where all the characters are ASCII.
631 LChar ored = 0; 631 LChar ored = 0;
632 for (int i = 0; i < length; ++i) { 632 for (int i = 0; i < length; ++i) {
633 LChar c = characters8()[i]; 633 LChar c = characters8()[i];
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 newImpl = createUninitialized(realLength, data16); 701 newImpl = createUninitialized(realLength, data16);
702 Unicode::toUpper(data16, realLength, source16, m_length, &error); 702 Unicode::toUpper(data16, realLength, source16, m_length, &error);
703 if (error) 703 if (error)
704 return this; 704 return this;
705 return newImpl.release(); 705 return newImpl.release();
706 } 706 }
707 707
708 static inline bool localeIdMatchesLang(const AtomicString& localeId, const char* lang) 708 static inline bool localeIdMatchesLang(const AtomicString& localeId, const char* lang)
709 { 709 {
710 size_t langLength = strlen(lang); 710 size_t langLength = strlen(lang);
711 CHECK(langLength >= 2 && langLength <= 3); 711 RELEASE_ASSERT(langLength >= 2 && langLength <= 3);
712 if (!localeId.impl() || !localeId.impl()->startsWithIgnoringCase(lang, langL ength)) 712 if (!localeId.impl() || !localeId.impl()->startsWithIgnoringCase(lang, langL ength))
713 return false; 713 return false;
714 if (localeId.impl()->length() == langLength) 714 if (localeId.impl()->length() == langLength)
715 return true; 715 return true;
716 const UChar maybeDelimiter = (*localeId.impl())[langLength]; 716 const UChar maybeDelimiter = (*localeId.impl())[langLength];
717 return maybeDelimiter == '-' || maybeDelimiter == '_' || maybeDelimiter == ' @'; 717 return maybeDelimiter == '-' || maybeDelimiter == '_' || maybeDelimiter == ' @';
718 } 718 }
719 719
720 typedef int32_t (*icuCaseConverter)(UChar*, int32_t, const UChar*, int32_t, cons t char*, UErrorCode*); 720 typedef int32_t (*icuCaseConverter)(UChar*, int32_t, const UChar*, int32_t, cons t char*, UErrorCode*);
721 721
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 815 }
816 UChar* data; 816 UChar* data;
817 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data); 817 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data);
818 for (unsigned i = 0; i < m_length; ++i) 818 for (unsigned i = 0; i < m_length; ++i)
819 data[i] = character; 819 data[i] = character;
820 return newImpl.release(); 820 return newImpl.release();
821 } 821 }
822 822
823 PassRefPtr<StringImpl> StringImpl::foldCase() 823 PassRefPtr<StringImpl> StringImpl::foldCase()
824 { 824 {
825 CHECK_LE(m_length, static_cast<unsigned>(numeric_limits<int32_t>::max())); 825 RELEASE_ASSERT(m_length <= static_cast<unsigned>(numeric_limits<int32_t>::ma x()));
826 int32_t length = m_length; 826 int32_t length = m_length;
827 827
828 if (is8Bit()) { 828 if (is8Bit()) {
829 // Do a faster loop for the case where all the characters are ASCII. 829 // Do a faster loop for the case where all the characters are ASCII.
830 LChar* data; 830 LChar* data;
831 RefPtr <StringImpl>newImpl = createUninitialized(m_length, data); 831 RefPtr <StringImpl>newImpl = createUninitialized(m_length, data);
832 LChar ored = 0; 832 LChar ored = 0;
833 833
834 for (int32_t i = 0; i < length; ++i) { 834 for (int32_t i = 0; i < length; ++i) {
835 LChar c = characters8()[i]; 835 LChar c = characters8()[i];
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 return WTF::find(characters8(), m_length, matchFunction, start); 1149 return WTF::find(characters8(), m_length, matchFunction, start);
1150 return WTF::find(characters16(), m_length, matchFunction, start); 1150 return WTF::find(characters16(), m_length, matchFunction, start);
1151 } 1151 }
1152 1152
1153 size_t StringImpl::find(const LChar* matchString, unsigned index) 1153 size_t StringImpl::find(const LChar* matchString, unsigned index)
1154 { 1154 {
1155 // Check for null or empty string to match against 1155 // Check for null or empty string to match against
1156 if (!matchString) 1156 if (!matchString)
1157 return kNotFound; 1157 return kNotFound;
1158 size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString) ); 1158 size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString) );
1159 CHECK_LE(matchStringLength, numeric_limits<unsigned>::max()); 1159 RELEASE_ASSERT(matchStringLength <= numeric_limits<unsigned>::max());
1160 unsigned matchLength = matchStringLength; 1160 unsigned matchLength = matchStringLength;
1161 if (!matchLength) 1161 if (!matchLength)
1162 return min(index, length()); 1162 return min(index, length());
1163 1163
1164 // Optimization 1: fast case for strings of length 1. 1164 // Optimization 1: fast case for strings of length 1.
1165 if (matchLength == 1) 1165 if (matchLength == 1)
1166 return WTF::find(characters16(), length(), *matchString, index); 1166 return WTF::find(characters16(), length(), *matchString, index);
1167 1167
1168 // Check index & matchLength are in range. 1168 // Check index & matchLength are in range.
1169 if (index > length()) 1169 if (index > length())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1211 }
1212 return index + i; 1212 return index + i;
1213 } 1213 }
1214 1214
1215 size_t StringImpl::findIgnoringCase(const LChar* matchString, unsigned index) 1215 size_t StringImpl::findIgnoringCase(const LChar* matchString, unsigned index)
1216 { 1216 {
1217 // Check for null or empty string to match against 1217 // Check for null or empty string to match against
1218 if (!matchString) 1218 if (!matchString)
1219 return kNotFound; 1219 return kNotFound;
1220 size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString) ); 1220 size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString) );
1221 CHECK_LE(matchStringLength, numeric_limits<unsigned>::max()); 1221 RELEASE_ASSERT(matchStringLength <= numeric_limits<unsigned>::max());
1222 unsigned matchLength = matchStringLength; 1222 unsigned matchLength = matchStringLength;
1223 if (!matchLength) 1223 if (!matchLength)
1224 return min(index, length()); 1224 return min(index, length());
1225 1225
1226 // Check index & matchLength are in range. 1226 // Check index & matchLength are in range.
1227 if (index > length()) 1227 if (index > length())
1228 return kNotFound; 1228 return kNotFound;
1229 unsigned searchLength = length() - index; 1229 unsigned searchLength = length() - index;
1230 if (matchLength > searchLength) 1230 if (matchLength > searchLength)
1231 return kNotFound; 1231 return kNotFound;
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 } 1757 }
1758 1758
1759 PassRefPtr<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToR eplace, StringImpl* str) 1759 PassRefPtr<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToR eplace, StringImpl* str)
1760 { 1760 {
1761 position = min(position, length()); 1761 position = min(position, length());
1762 lengthToReplace = min(lengthToReplace, length() - position); 1762 lengthToReplace = min(lengthToReplace, length() - position);
1763 unsigned lengthToInsert = str ? str->length() : 0; 1763 unsigned lengthToInsert = str ? str->length() : 0;
1764 if (!lengthToReplace && !lengthToInsert) 1764 if (!lengthToReplace && !lengthToInsert)
1765 return this; 1765 return this;
1766 1766
1767 CHECK_LT(length() - lengthToReplace, numeric_limits<unsigned>::max() - lengt hToInsert); 1767 RELEASE_ASSERT((length() - lengthToReplace) < (numeric_limits<unsigned>::max () - lengthToInsert));
1768 1768
1769 if (is8Bit() && (!str || str->is8Bit())) { 1769 if (is8Bit() && (!str || str->is8Bit())) {
1770 LChar* data; 1770 LChar* data;
1771 RefPtr<StringImpl> newImpl = 1771 RefPtr<StringImpl> newImpl =
1772 createUninitialized(length() - lengthToReplace + lengthToInsert, data); 1772 createUninitialized(length() - lengthToReplace + lengthToInsert, data);
1773 memcpy(data, characters8(), position * sizeof(LChar)); 1773 memcpy(data, characters8(), position * sizeof(LChar));
1774 if (str) 1774 if (str)
1775 memcpy(data + position, str->characters8(), lengthToInsert * sizeof( LChar)); 1775 memcpy(data + position, str->characters8(), lengthToInsert * sizeof( LChar));
1776 memcpy(data + position + lengthToInsert, characters8() + position + leng thToReplace, 1776 memcpy(data + position + lengthToInsert, characters8() + position + leng thToReplace,
1777 (length() - position - lengthToReplace) * sizeof(LChar)); 1777 (length() - position - lengthToReplace) * sizeof(LChar));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 // Count the matches. 1823 // Count the matches.
1824 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) { 1824 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) {
1825 ++matchCount; 1825 ++matchCount;
1826 ++srcSegmentStart; 1826 ++srcSegmentStart;
1827 } 1827 }
1828 1828
1829 // If we have 0 matches then we don't have to do any more work. 1829 // If we have 0 matches then we don't have to do any more work.
1830 if (!matchCount) 1830 if (!matchCount)
1831 return this; 1831 return this;
1832 1832
1833 CHECK(!repStrLength || matchCount <= numeric_limits<unsigned>::max() / repSt rLength); 1833 RELEASE_ASSERT(!repStrLength || matchCount <= numeric_limits<unsigned>::max( ) / repStrLength);
1834 1834
1835 unsigned replaceSize = matchCount * repStrLength; 1835 unsigned replaceSize = matchCount * repStrLength;
1836 unsigned newSize = m_length - matchCount; 1836 unsigned newSize = m_length - matchCount;
1837 CHECK_LT(newSize, numeric_limits<unsigned>::max() - replaceSize); 1837 RELEASE_ASSERT(newSize < (numeric_limits<unsigned>::max() - replaceSize));
1838 1838
1839 newSize += replaceSize; 1839 newSize += replaceSize;
1840 1840
1841 // Construct the new data. 1841 // Construct the new data.
1842 size_t srcSegmentEnd; 1842 size_t srcSegmentEnd;
1843 unsigned srcSegmentLength; 1843 unsigned srcSegmentLength;
1844 srcSegmentStart = 0; 1844 srcSegmentStart = 0;
1845 unsigned dstOffset = 0; 1845 unsigned dstOffset = 0;
1846 1846
1847 if (is8Bit()) { 1847 if (is8Bit()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 // Count the matches. 1898 // Count the matches.
1899 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) { 1899 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) {
1900 ++matchCount; 1900 ++matchCount;
1901 ++srcSegmentStart; 1901 ++srcSegmentStart;
1902 } 1902 }
1903 1903
1904 // If we have 0 matches then we don't have to do any more work. 1904 // If we have 0 matches then we don't have to do any more work.
1905 if (!matchCount) 1905 if (!matchCount)
1906 return this; 1906 return this;
1907 1907
1908 CHECK(!repStrLength || matchCount <= numeric_limits<unsigned>::max() / repSt rLength); 1908 RELEASE_ASSERT(!repStrLength || matchCount <= numeric_limits<unsigned>::max( ) / repStrLength);
1909 1909
1910 unsigned replaceSize = matchCount * repStrLength; 1910 unsigned replaceSize = matchCount * repStrLength;
1911 unsigned newSize = m_length - matchCount; 1911 unsigned newSize = m_length - matchCount;
1912 CHECK_LT(newSize, numeric_limits<unsigned>::max() - replaceSize); 1912 RELEASE_ASSERT(newSize < (numeric_limits<unsigned>::max() - replaceSize));
1913 1913
1914 newSize += replaceSize; 1914 newSize += replaceSize;
1915 1915
1916 // Construct the new data. 1916 // Construct the new data.
1917 size_t srcSegmentEnd; 1917 size_t srcSegmentEnd;
1918 unsigned srcSegmentLength; 1918 unsigned srcSegmentLength;
1919 srcSegmentStart = 0; 1919 srcSegmentStart = 0;
1920 unsigned dstOffset = 0; 1920 unsigned dstOffset = 0;
1921 1921
1922 if (is8Bit()) { 1922 if (is8Bit()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) { 1983 while ((srcSegmentStart = find(pattern, srcSegmentStart)) != kNotFound) {
1984 ++matchCount; 1984 ++matchCount;
1985 srcSegmentStart += patternLength; 1985 srcSegmentStart += patternLength;
1986 } 1986 }
1987 1987
1988 // If we have 0 matches, we don't have to do any more work 1988 // If we have 0 matches, we don't have to do any more work
1989 if (!matchCount) 1989 if (!matchCount)
1990 return this; 1990 return this;
1991 1991
1992 unsigned newSize = m_length - matchCount * patternLength; 1992 unsigned newSize = m_length - matchCount * patternLength;
1993 CHECK(!repStrLength || matchCount <= numeric_limits<unsigned>::max() / repSt rLength); 1993 RELEASE_ASSERT(!repStrLength || matchCount <= numeric_limits<unsigned>::max( ) / repStrLength);
1994 1994
1995 CHECK_LE(newSize, numeric_limits<unsigned>::max() - matchCount * repStrLengt h); 1995 RELEASE_ASSERT(newSize <= (numeric_limits<unsigned>::max() - matchCount * re pStrLength));
1996 1996
1997 newSize += matchCount * repStrLength; 1997 newSize += matchCount * repStrLength;
1998 1998
1999 1999
2000 // Construct the new data 2000 // Construct the new data
2001 size_t srcSegmentEnd; 2001 size_t srcSegmentEnd;
2002 unsigned srcSegmentLength; 2002 unsigned srcSegmentLength;
2003 srcSegmentStart = 0; 2003 srcSegmentStart = 0;
2004 unsigned dstOffset = 0; 2004 unsigned dstOffset = 0;
2005 bool srcIs8Bit = is8Bit(); 2005 bool srcIs8Bit = is8Bit();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 if (b->is8Bit()) 2290 if (b->is8Bit())
2291 return equalIgnoringASCIICase(a->characters16(), b->characters8(), lengt h); 2291 return equalIgnoringASCIICase(a->characters16(), b->characters8(), lengt h);
2292 return equalIgnoringASCIICase(a->characters16(), b->characters16(), length); 2292 return equalIgnoringASCIICase(a->characters16(), b->characters16(), length);
2293 } 2293 }
2294 2294
2295 bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b) 2295 bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b)
2296 { 2296 {
2297 if (!a || !b) 2297 if (!a || !b)
2298 return !a == !b; 2298 return !a == !b;
2299 size_t length = strlen(reinterpret_cast<const char*>(b)); 2299 size_t length = strlen(reinterpret_cast<const char*>(b));
2300 CHECK_LE(length, numeric_limits<unsigned>::max()); 2300 RELEASE_ASSERT(length <= numeric_limits<unsigned>::max());
2301 if (length != a->length()) 2301 if (length != a->length())
2302 return false; 2302 return false;
2303 return equalSubstringIgnoringASCIICase(a, 0, b, length); 2303 return equalSubstringIgnoringASCIICase(a, 0, b, length);
2304 } 2304 }
2305 2305
2306 size_t StringImpl::sizeInBytes() const 2306 size_t StringImpl::sizeInBytes() const
2307 { 2307 {
2308 size_t size = length(); 2308 size_t size = length();
2309 if (!is8Bit()) 2309 if (!is8Bit())
2310 size *= 2; 2310 size *= 2;
(...skipping 11 matching lines...) Expand all
2322 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2322 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2323 // TODO(rob.buis) implement upper-casing rules for lt 2323 // TODO(rob.buis) implement upper-casing rules for lt
2324 // like in StringImpl::upper(locale). 2324 // like in StringImpl::upper(locale).
2325 } 2325 }
2326 } 2326 }
2327 2327
2328 return toUpper(c); 2328 return toUpper(c);
2329 } 2329 }
2330 2330
2331 } // namespace WTF 2331 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/TextCodecUTF16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698