Changeset 127191 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Aug 30, 2012, 2:23:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r126494 r127191 38 38 JSString* jsEmptyString(JSGlobalData*); 39 39 JSString* jsEmptyString(ExecState*); 40 JSString* jsString(JSGlobalData*, const UString&); // returns empty string if passed null string41 JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string40 JSString* jsString(JSGlobalData*, const String&); // returns empty string if passed null string 41 JSString* jsString(ExecState*, const String&); // returns empty string if passed null string 42 42 43 43 JSString* jsSingleCharacterString(JSGlobalData*, UChar); 44 44 JSString* jsSingleCharacterString(ExecState*, UChar); 45 JSString* jsSingleCharacterSubstring(ExecState*, const UString&, unsigned offset);46 JSString* jsSubstring(JSGlobalData*, const UString&, unsigned offset, unsigned length);47 JSString* jsSubstring(ExecState*, const UString&, unsigned offset, unsigned length);45 JSString* jsSingleCharacterSubstring(ExecState*, const String&, unsigned offset); 46 JSString* jsSubstring(JSGlobalData*, const String&, unsigned offset, unsigned length); 47 JSString* jsSubstring(ExecState*, const String&, unsigned offset, unsigned length); 48 48 49 49 // Non-trivial strings are two or more characters long. 50 50 // These functions are faster than just calling jsString. 51 JSString* jsNontrivialString(JSGlobalData*, const UString&);52 JSString* jsNontrivialString(ExecState*, const UString&);51 JSString* jsNontrivialString(JSGlobalData*, const String&); 52 JSString* jsNontrivialString(ExecState*, const String&); 53 53 JSString* jsNontrivialString(JSGlobalData*, const char*); 54 54 JSString* jsNontrivialString(ExecState*, const char*); … … 56 56 // Should be used for strings that are owned by an object that will 57 57 // likely outlive the JSValue this makes, such as the parse tree or a 58 // DOM object that contains a UString59 JSString* jsOwnedString(JSGlobalData*, const UString&);60 JSString* jsOwnedString(ExecState*, const UString&);58 // DOM object that contains a String 59 JSString* jsOwnedString(JSGlobalData*, const String&); 60 JSString* jsOwnedString(ExecState*, const String&); 61 61 62 62 JSRopeString* jsStringBuilder(JSGlobalData*); … … 137 137 } 138 138 139 const UString& value(ExecState*) const;140 const UString& tryGetValue() const;139 const String& value(ExecState*) const; 140 const String& tryGetValue() const; 141 141 unsigned length() { return m_length; } 142 142 … … 191 191 }; 192 192 193 // A string is represented either by a UString or a rope of fibers.193 // A string is represented either by a String or a rope of fibers. 194 194 unsigned m_length; 195 mutable UString m_value;195 mutable String m_value; 196 196 197 197 private: … … 204 204 static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&); 205 205 206 UString& string() { ASSERT(!isRope()); return m_value; }206 String& string() { ASSERT(!isRope()); return m_value; } 207 207 208 208 friend JSValue jsString(ExecState*, JSString*, JSString*); … … 341 341 if (c <= maxSingleCharacterString) 342 342 return globalData->smallStrings.singleCharacterString(globalData, c); 343 return JSString::create(*globalData, UString(&c, 1).impl());344 } 345 346 ALWAYS_INLINE JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset)343 return JSString::create(*globalData, String(&c, 1).impl()); 344 } 345 346 ALWAYS_INLINE JSString* jsSingleCharacterSubstring(ExecState* exec, const String& s, unsigned offset) 347 347 { 348 348 JSGlobalData* globalData = &exec->globalData(); … … 359 359 ASSERT(s[0]); 360 360 ASSERT(s[1]); 361 return JSString::create(*globalData, UString(s).impl());362 } 363 364 inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s)361 return JSString::create(*globalData, String(s).impl()); 362 } 363 364 inline JSString* jsNontrivialString(JSGlobalData* globalData, const String& s) 365 365 { 366 366 ASSERT(s.length() > 1); … … 368 368 } 369 369 370 inline const UString& JSString::value(ExecState* exec) const370 inline const String& JSString::value(ExecState* exec) const 371 371 { 372 372 if (isRope()) … … 375 375 } 376 376 377 inline const UString& JSString::tryGetValue() const377 inline const String& JSString::tryGetValue() const 378 378 { 379 379 if (isRope()) … … 391 391 } 392 392 393 inline JSString* jsString(JSGlobalData* globalData, const UString& s)393 inline JSString* jsString(JSGlobalData* globalData, const String& s) 394 394 { 395 395 int size = s.length(); … … 415 415 } 416 416 417 inline JSString* jsSubstring8(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)417 inline JSString* jsSubstring8(JSGlobalData* globalData, const String& s, unsigned offset, unsigned length) 418 418 { 419 419 ASSERT(offset <= static_cast<unsigned>(s.length())); … … 430 430 } 431 431 432 inline JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)432 inline JSString* jsSubstring(JSGlobalData* globalData, const String& s, unsigned offset, unsigned length) 433 433 { 434 434 ASSERT(offset <= static_cast<unsigned>(s.length())); … … 445 445 } 446 446 447 inline JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)447 inline JSString* jsOwnedString(JSGlobalData* globalData, const String& s) 448 448 { 449 449 int size = s.length(); … … 464 464 465 465 inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&exec->globalData()); } 466 inline JSString* jsString(ExecState* exec, const UString& s) { return jsString(&exec->globalData(), s); }466 inline JSString* jsString(ExecState* exec, const String& s) { return jsString(&exec->globalData(), s); } 467 467 inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&exec->globalData(), c); } 468 inline JSString* jsSubstring8(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring8(&exec->globalData(), s, offset, length); }469 inline JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); }470 inline JSString* jsNontrivialString(ExecState* exec, const UString& s) { return jsNontrivialString(&exec->globalData(), s); }468 inline JSString* jsSubstring8(ExecState* exec, const String& s, unsigned offset, unsigned length) { return jsSubstring8(&exec->globalData(), s, offset, length); } 469 inline JSString* jsSubstring(ExecState* exec, const String& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); } 470 inline JSString* jsNontrivialString(ExecState* exec, const String& s) { return jsNontrivialString(&exec->globalData(), s); } 471 471 inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&exec->globalData(), s); } 472 inline JSString* jsOwnedString(ExecState* exec, const UString& s) { return jsOwnedString(&exec->globalData(), s); }472 inline JSString* jsOwnedString(ExecState* exec, const String& s) { return jsOwnedString(&exec->globalData(), s); } 473 473 474 474 ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot) … … 528 528 } 529 529 530 inline UString JSValue::toUString(ExecState* exec) const530 inline String JSValue::toWTFString(ExecState* exec) const 531 531 { 532 532 if (isString()) 533 533 return static_cast<JSString*>(asCell())->value(exec); 534 return to UStringSlowCase(exec);535 } 536 537 ALWAYS_INLINE UString inlineJSValueNotStringtoUString(const JSValue& value, ExecState* exec)534 return toWTFStringSlowCase(exec); 535 } 536 537 ALWAYS_INLINE String inlineJSValueNotStringtoString(const JSValue& value, ExecState* exec) 538 538 { 539 539 JSGlobalData& globalData = exec->globalData(); … … 553 553 } 554 554 555 ALWAYS_INLINE UString JSValue::toUStringInline(ExecState* exec) const555 ALWAYS_INLINE String JSValue::toWTFStringInline(ExecState* exec) const 556 556 { 557 557 if (isString()) 558 558 return static_cast<JSString*>(asCell())->value(exec); 559 559 560 return inlineJSValueNotStringto UString(*this, exec);560 return inlineJSValueNotStringtoString(*this, exec); 561 561 } 562 562
Note:
See TracChangeset
for help on using the changeset viewer.