Changeset 54788 in webkit for trunk/JavaScriptCore/runtime/UString.h
- Timestamp:
- Feb 15, 2010, 12:59:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UString.h
r54747 r54788 327 327 }; 328 328 329 inline void sumWithOverflow(unsigned& total, unsigned addend, bool overflow) 330 { 331 unsigned oldTotal = total; 332 total = oldTotal + addend; 333 if (total < oldTotal) 334 overflow = true; 335 } 336 329 337 template<typename StringType1, typename StringType2> 330 338 PassRefPtr<UStringImpl> tryMakeString(StringType1 string1, StringType2 string2) … … 334 342 335 343 UChar* buffer; 336 unsigned length = adapter1.length() + adapter2.length(); 344 bool overflow = false; 345 unsigned length = adapter1.length(); 346 sumWithOverflow(length, adapter2.length(), overflow); 347 if (overflow) 348 return 0; 337 349 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 338 350 if (!resultImpl) … … 355 367 356 368 UChar* buffer; 357 unsigned length = adapter1.length() + adapter2.length() + adapter3.length(); 369 bool overflow = false; 370 unsigned length = adapter1.length(); 371 sumWithOverflow(length, adapter2.length(), overflow); 372 sumWithOverflow(length, adapter3.length(), overflow); 373 if (overflow) 374 return 0; 358 375 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 359 376 if (!resultImpl) … … 379 396 380 397 UChar* buffer; 381 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length(); 398 bool overflow = false; 399 unsigned length = adapter1.length(); 400 sumWithOverflow(length, adapter2.length(), overflow); 401 sumWithOverflow(length, adapter3.length(), overflow); 402 sumWithOverflow(length, adapter4.length(), overflow); 403 if (overflow) 404 return 0; 382 405 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 383 406 if (!resultImpl) … … 406 429 407 430 UChar* buffer; 408 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length(); 431 bool overflow = false; 432 unsigned length = adapter1.length(); 433 sumWithOverflow(length, adapter2.length(), overflow); 434 sumWithOverflow(length, adapter3.length(), overflow); 435 sumWithOverflow(length, adapter4.length(), overflow); 436 sumWithOverflow(length, adapter5.length(), overflow); 437 if (overflow) 438 return 0; 409 439 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 410 440 if (!resultImpl) … … 436 466 437 467 UChar* buffer; 438 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length(); 468 bool overflow = false; 469 unsigned length = adapter1.length(); 470 sumWithOverflow(length, adapter2.length(), overflow); 471 sumWithOverflow(length, adapter3.length(), overflow); 472 sumWithOverflow(length, adapter4.length(), overflow); 473 sumWithOverflow(length, adapter5.length(), overflow); 474 sumWithOverflow(length, adapter6.length(), overflow); 475 if (overflow) 476 return 0; 439 477 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 440 478 if (!resultImpl) … … 469 507 470 508 UChar* buffer; 471 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length() + adapter7.length(); 509 bool overflow = false; 510 unsigned length = adapter1.length(); 511 sumWithOverflow(length, adapter2.length(), overflow); 512 sumWithOverflow(length, adapter3.length(), overflow); 513 sumWithOverflow(length, adapter4.length(), overflow); 514 sumWithOverflow(length, adapter5.length(), overflow); 515 sumWithOverflow(length, adapter6.length(), overflow); 516 sumWithOverflow(length, adapter7.length(), overflow); 517 if (overflow) 518 return 0; 472 519 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 473 520 if (!resultImpl) … … 505 552 506 553 UChar* buffer; 507 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length() + adapter7.length() + adapter8.length(); 554 bool overflow = false; 555 unsigned length = adapter1.length(); 556 sumWithOverflow(length, adapter2.length(), overflow); 557 sumWithOverflow(length, adapter3.length(), overflow); 558 sumWithOverflow(length, adapter4.length(), overflow); 559 sumWithOverflow(length, adapter5.length(), overflow); 560 sumWithOverflow(length, adapter6.length(), overflow); 561 sumWithOverflow(length, adapter7.length(), overflow); 562 sumWithOverflow(length, adapter8.length(), overflow); 563 if (overflow) 564 return 0; 508 565 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 509 566 if (!resultImpl)
Note:
See TracChangeset
for help on using the changeset viewer.