Changeset 194310 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Dec 18, 2015, 6:32:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r190601 r194310 433 433 class JSString::SafeView { 434 434 public: 435 SafeView();436 435 explicit SafeView(ExecState&, const JSString&); 437 operator StringView() const;438 436 StringView get() const; 439 437 438 bool is8Bit() const { return m_string->is8Bit(); } 439 unsigned length() const { return m_string->length(); } 440 const LChar* characters8() const { return get().characters8(); } 441 const UChar* characters16() const { return get().characters16(); } 442 UChar operator[](unsigned index) const { return get()[index]; } 443 440 444 private: 441 ExecState * m_state { nullptr };445 ExecState& m_state; 442 446 443 447 // The following pointer is marked "volatile" to make the compiler leave it on the stack … … 445 449 // That's needed to prevent garbage collecting the string and possibly deleting the block 446 450 // with the characters in it, and then using the StringView after that. 447 const JSString* volatile m_string { nullptr };451 const JSString* volatile m_string; 448 452 }; 449 453 … … 708 712 } 709 713 710 inline JSString::SafeView::SafeView()711 {712 }713 714 714 inline JSString::SafeView::SafeView(ExecState& state, const JSString& string) 715 : m_state( &state)715 : m_state(state) 716 716 , m_string(&string) 717 717 { 718 718 } 719 719 720 inline JSString::SafeView::operator StringView() const721 {722 return m_string->unsafeView(*m_state);723 }724 725 720 inline StringView JSString::SafeView::get() const 726 721 { 727 return *this;722 return m_string->unsafeView(m_state); 728 723 } 729 724
Note:
See TracChangeset
for help on using the changeset viewer.