Changeset 53320 in webkit for trunk/JavaScriptCore/runtime/UString.h
- Timestamp:
- Jan 14, 2010, 10:43:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UString.h
r52463 r53320 104 104 } 105 105 106 static UString createNonCopying(UChar* c, int length); 106 template<size_t inlineCapacity> 107 static PassRefPtr<UStringImpl> adopt(Vector<UChar, inlineCapacity>& vector) 108 { 109 return Rep::adopt(vector); 110 } 111 107 112 static UString createFromUTF8(const char*); 108 static UString createUninitialized(unsigned length, UChar*& output);109 113 110 114 static UString from(int); … … 274 278 275 279 struct IdentifierRepHash : PtrHash<RefPtr<JSC::UString::Rep> > { 276 static unsigned hash(const RefPtr<JSC::UString::Rep>& key) { return key-> computedHash(); }277 static unsigned hash(JSC::UString::Rep* key) { return key-> computedHash(); }280 static unsigned hash(const RefPtr<JSC::UString::Rep>& key) { return key->existingHash(); } 281 static unsigned hash(JSC::UString::Rep* key) { return key->existingHash(); } 278 282 }; 279 283 … … 358 362 UChar* buffer; 359 363 unsigned length = adapter1.length() + adapter2.length(); 360 UString resultString = UString::createUninitialized(length, buffer);361 if (! buffer)362 return UString(); 363 364 UChar* result = buffer; 365 adapter1.writeTo(result); 366 result += adapter1.length(); 367 adapter2.writeTo(result); 368 369 return result String;364 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 365 if (!resultImpl) 366 return UString(); 367 368 UChar* result = buffer; 369 adapter1.writeTo(result); 370 result += adapter1.length(); 371 adapter2.writeTo(result); 372 373 return resultImpl; 370 374 } 371 375 … … 379 383 UChar* buffer; 380 384 unsigned length = adapter1.length() + adapter2.length() + adapter3.length(); 381 UString resultString = UString::createUninitialized(length, buffer);382 if (! buffer)385 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 386 if (!resultImpl) 383 387 return UString(); 384 388 … … 390 394 adapter3.writeTo(result); 391 395 392 return result String;396 return resultImpl; 393 397 } 394 398 … … 403 407 UChar* buffer; 404 408 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length(); 405 UString resultString = UString::createUninitialized(length, buffer);406 if (! buffer)409 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 410 if (!resultImpl) 407 411 return UString(); 408 412 … … 416 420 adapter4.writeTo(result); 417 421 418 return result String;422 return resultImpl; 419 423 } 420 424 … … 430 434 UChar* buffer; 431 435 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length(); 432 UString resultString = UString::createUninitialized(length, buffer);433 if (! buffer)436 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 437 if (!resultImpl) 434 438 return UString(); 435 439 … … 445 449 adapter5.writeTo(result); 446 450 447 return result String;451 return resultImpl; 448 452 } 449 453 … … 460 464 UChar* buffer; 461 465 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length(); 462 UString resultString = UString::createUninitialized(length, buffer);463 if (! buffer)466 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 467 if (!resultImpl) 464 468 return UString(); 465 469 … … 477 481 adapter6.writeTo(result); 478 482 479 return result String;483 return resultImpl; 480 484 } 481 485 … … 493 497 UChar* buffer; 494 498 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length() + adapter7.length(); 495 UString resultString = UString::createUninitialized(length, buffer);496 if (! buffer)499 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 500 if (!resultImpl) 497 501 return UString(); 498 502 … … 512 516 adapter7.writeTo(result); 513 517 514 return result String;518 return resultImpl; 515 519 } 516 520 … … 529 533 UChar* buffer; 530 534 unsigned length = adapter1.length() + adapter2.length() + adapter3.length() + adapter4.length() + adapter5.length() + adapter6.length() + adapter7.length() + adapter8.length(); 531 UString resultString = UString::createUninitialized(length, buffer);532 if (! buffer)535 PassRefPtr<UStringImpl> resultImpl = UStringImpl::tryCreateUninitialized(length, buffer); 536 if (!resultImpl) 533 537 return UString(); 534 538 … … 550 554 adapter8.writeTo(result); 551 555 552 return result String;556 return resultImpl; 553 557 } 554 558
Note:
See TracChangeset
for help on using the changeset viewer.