Changeset 53320 in webkit for trunk/JavaScriptCore/runtime/UString.cpp
- Timestamp:
- Jan 14, 2010, 10:43:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UString.cpp
r52791 r53320 171 171 size_t length = strlen(c); 172 172 UChar* d; 173 PassRefPtr<UStringImpl> result = UStringImpl:: createUninitialized(length, d);173 PassRefPtr<UStringImpl> result = UStringImpl::tryCreateUninitialized(length, d); 174 174 if (!result) 175 175 return &UString::Rep::null(); … … 189 189 190 190 UChar* d; 191 PassRefPtr<UStringImpl> result = UStringImpl:: createUninitialized(length, d);191 PassRefPtr<UStringImpl> result = UStringImpl::tryCreateUninitialized(length, d); 192 192 if (!result) 193 193 return &UString::Rep::null(); … … 213 213 m_rep = &Rep::empty(); 214 214 else 215 m_rep = Rep::createCopying(c, length); 216 } 217 218 UString UString::createNonCopying(UChar* c, int length) 219 { 220 if (length == 0) 221 return UString(&Rep::empty()); 222 else 223 return Rep::create(c, length); 215 m_rep = Rep::create(c, length); 224 216 } 225 217 … … 236 228 237 229 return UString(buffer.data(), p - buffer.data()); 238 }239 240 UString UString::createUninitialized(unsigned length, UChar*& output)241 {242 if (!length) {243 output = &sharedEmptyChar;244 return UString(&Rep::empty());245 }246 247 if (PassRefPtr<UStringImpl> result = UStringImpl::createUninitialized(length, output))248 return result;249 output = 0;250 return UString();251 230 } 252 231 … … 391 370 392 371 UChar* buffer; 393 if (!UStringImpl::allocChars(totalLength).getValue(buffer)) 372 PassRefPtr<Rep> rep = Rep::tryCreateUninitialized(totalLength, buffer); 373 if (!rep) 394 374 return null(); 395 375 … … 407 387 } 408 388 409 return UString::Rep::create(buffer, totalLength);389 return rep; 410 390 } 411 391 … … 420 400 421 401 UChar* buffer; 422 if (!UStringImpl::allocChars(totalLength).getValue(buffer)) 402 PassRefPtr<Rep> rep = Rep::tryCreateUninitialized(totalLength, buffer); 403 if (!rep) 423 404 return null(); 424 405 … … 428 409 UStringImpl::copyChars(buffer + rangeStart + replacementLength, data() + rangeEnd, size() - rangeEnd); 429 410 430 return UString::Rep::create(buffer, totalLength);411 return rep; 431 412 } 432 413 … … 489 470 490 471 int l = static_cast<int>(strlen(c)); 491 UChar* d; 492 if (!UStringImpl::allocChars(l).getValue(d)) { 472 UChar* d = 0; 473 m_rep = Rep::tryCreateUninitialized(l, d); 474 if (m_rep) { 475 for (int i = 0; i < l; i++) 476 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend 477 } else 493 478 makeNull(); 494 return *this;495 }496 for (int i = 0; i < l; i++)497 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend498 m_rep = Rep::create(d, l);499 479 500 480 return *this;
Note:
See TracChangeset
for help on using the changeset viewer.