Changeset 35458 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Jul 30, 2008, 1:16:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r35418 r35458 200 200 r->preCapacity = 0; 201 201 202 r->checkConsistency(); 203 202 204 // steal the single reference this Rep was created with 203 205 return adoptRef(r); … … 207 209 { 208 210 ASSERT(base); 211 base->checkConsistency(); 209 212 210 213 int baseOffset = base->offset; … … 229 232 r->preCapacity = 0; 230 233 234 r->checkConsistency(); 235 231 236 // steal the single reference this Rep was created with 232 237 return adoptRef(r); … … 249 254 void UString::Rep::destroy() 250 255 { 256 checkConsistency(); 257 251 258 // Static null and empty strings can never be destroyed, but we cannot rely on 252 259 // reference counting, because ref/deref are not thread-safe. … … 356 363 } 357 364 365 #ifndef NDEBUG 366 void UString::Rep::checkConsistency() const 367 { 368 // Only base strings have non-zero shared data. 369 if (this != baseString) { 370 ASSERT(!buf); 371 ASSERT(!usedCapacity); 372 ASSERT(!capacity); 373 ASSERT(!usedPreCapacity); 374 ASSERT(!preCapacity); 375 } 376 377 // There is no recursion for base strings. 378 ASSERT(baseString == baseString->baseString); 379 380 if (isStatic()) { 381 // There are only two static strings: null and empty. 382 ASSERT(!len); 383 384 // Static strings cannot get in identifier tables, because they are globally shared. 385 ASSERT(!identifierTable()); 386 } 387 388 // The string fits in buffer. 389 ASSERT(baseString->usedPreCapacity <= baseString->preCapacity); 390 ASSERT(baseString->usedCapacity <= baseString->capacity); 391 ASSERT(-offset <= baseString->usedPreCapacity); 392 ASSERT(offset + len <= baseString->usedCapacity); 393 } 394 #endif 395 358 396 // put these early so they can be inlined 359 397 inline size_t UString::expandedSize(size_t size, size_t otherSize) const … … 384 422 void UString::expandCapacity(int requiredLength) 385 423 { 424 m_rep->checkConsistency(); 425 386 426 Rep* r = m_rep->baseString; 387 427 … … 399 439 if (requiredLength > r->usedCapacity) 400 440 r->usedCapacity = requiredLength; 441 442 m_rep->checkConsistency(); 401 443 } 402 444 403 445 void UString::expandPreCapacity(int requiredPreCap) 404 446 { 447 m_rep->checkConsistency(); 448 405 449 Rep* r = m_rep->baseString; 406 450 … … 422 466 if (requiredPreCap > r->usedPreCapacity) 423 467 r->usedPreCapacity = requiredPreCap; 468 469 m_rep->checkConsistency(); 424 470 } 425 471 … … 476 522 UString::UString(const UString& a, const UString& b) 477 523 { 524 a.rep()->checkConsistency(); 525 b.rep()->checkConsistency(); 526 478 527 int aSize = a.size(); 479 528 int aOffset = a.m_rep->offset; … … 527 576 } 528 577 } 578 a.rep()->checkConsistency(); 579 b.rep()->checkConsistency(); 580 m_rep->checkConsistency(); 529 581 } 530 582 … … 679 731 UString UString::spliceSubstringsWithSeparators(const Range* substringRanges, int rangeCount, const UString* separators, int separatorCount) const 680 732 { 733 m_rep->checkConsistency(); 734 681 735 if (rangeCount == 1 && separatorCount == 0) { 682 736 int thisSize = size(); … … 719 773 UString& UString::append(const UString &t) 720 774 { 775 m_rep->checkConsistency(); 776 t.rep()->checkConsistency(); 777 721 778 int thisSize = size(); 722 779 int thisOffset = m_rep->offset; … … 759 816 } 760 817 818 m_rep->checkConsistency(); 819 t.rep()->checkConsistency(); 820 761 821 return *this; 762 822 } … … 764 824 UString& UString::append(const UChar* tData, int tSize) 765 825 { 826 m_rep->checkConsistency(); 827 766 828 int thisSize = size(); 767 829 int thisOffset = m_rep->offset; … … 803 865 } 804 866 867 m_rep->checkConsistency(); 868 805 869 return *this; 806 870 } … … 808 872 UString& UString::append(const char* t) 809 873 { 874 m_rep->checkConsistency(); 875 810 876 int thisSize = size(); 811 877 int thisOffset = m_rep->offset; … … 853 919 } 854 920 921 m_rep->checkConsistency(); 922 855 923 return *this; 856 924 } … … 858 926 UString& UString::append(UChar c) 859 927 { 928 m_rep->checkConsistency(); 929 860 930 int thisOffset = m_rep->offset; 861 931 int length = size(); … … 903 973 } 904 974 } 975 976 m_rep->checkConsistency(); 905 977 906 978 return *this;
Note:
See TracChangeset
for help on using the changeset viewer.