Changeset 185899 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Jun 23, 2015, 7:33:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r185659 r185899 63 63 JSRopeString* jsStringBuilder(VM*); 64 64 65 struct StringViewWithUnderlyingString { 66 StringView view; 67 String underlyingString; 68 }; 69 65 70 class JSString : public JSCell { 66 71 public: … … 145 150 RefPtr<AtomicStringImpl> toExistingAtomicString(ExecState*) const; 146 151 StringView view(ExecState*) const; 152 StringViewWithUnderlyingString viewWithUnderlyingString(ExecState&) const; 147 153 const String& value(ExecState*) const; 148 154 const String& tryGetValue() const; … … 385 391 void clearFibers() const; 386 392 StringView view(ExecState*) const; 393 StringViewWithUnderlyingString viewWithUnderlyingString(ExecState&) const; 387 394 388 395 WriteBarrierBase<JSString>& fiber(unsigned i) const … … 674 681 } 675 682 676 ALWAYS_INLINE String inlineJSValueNotStringtoString(const JSValue& value, ExecState* exec)677 {678 VM& vm = exec->vm();679 if (value.isInt32())680 return vm.numericStrings.add(value.asInt32());681 if (value.isDouble())682 return vm.numericStrings.add(value.asDouble());683 if (value.isTrue())684 return vm.propertyNames->trueKeyword.string();685 if (value.isFalse())686 return vm.propertyNames->falseKeyword.string();687 if (value.isNull())688 return vm.propertyNames->nullKeyword.string();689 if (value.isUndefined())690 return vm.propertyNames->undefinedKeyword.string();691 return value.toString(exec)->value(exec);692 }693 694 ALWAYS_INLINE String JSValue::toWTFStringInline(ExecState* exec) const695 {696 if (isString())697 return static_cast<JSString*>(asCell())->value(exec);698 699 return inlineJSValueNotStringtoString(*this, exec);700 }701 702 683 ALWAYS_INLINE StringView JSRopeString::view(ExecState* exec) const 703 684 { … … 711 692 } 712 693 694 ALWAYS_INLINE StringViewWithUnderlyingString JSRopeString::viewWithUnderlyingString(ExecState& state) const 695 { 696 if (isSubstring()) { 697 auto& base = substringBase()->m_value; 698 if (is8Bit()) 699 return { { base.characters8() + substringOffset(), m_length }, base }; 700 return { { base.characters16() + substringOffset(), m_length }, base }; 701 } 702 resolveRope(&state); 703 return { m_value, m_value }; 704 } 705 713 706 ALWAYS_INLINE StringView JSString::view(ExecState* exec) const 714 707 { … … 718 711 } 719 712 713 ALWAYS_INLINE StringViewWithUnderlyingString JSString::viewWithUnderlyingString(ExecState& state) const 714 { 715 if (isRope()) 716 return static_cast<const JSRopeString&>(*this).viewWithUnderlyingString(state); 717 return { m_value, m_value }; 718 } 719 720 720 inline bool JSString::isSubstring() const 721 721 {
Note:
See TracChangeset
for help on using the changeset viewer.