summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/JSString.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/runtime/JSString.h')
-rw-r--r--JavaScriptCore/runtime/JSString.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h
index 51b9f2d..fefffde 100644
--- a/JavaScriptCore/runtime/JSString.h
+++ b/JavaScriptCore/runtime/JSString.h
@@ -356,6 +356,7 @@ namespace JSC {
}
void resolveRope(ExecState*) const;
+ JSString* substringFromRope(ExecState*, unsigned offset, unsigned length);
void appendStringInConstruct(unsigned& index, const UString& string)
{
@@ -435,6 +436,7 @@ namespace JSC {
friend JSValue jsString(ExecState* exec, Register* strings, unsigned count);
friend JSValue jsString(ExecState* exec, JSValue thisValue);
friend JSString* jsStringWithFinalizer(ExecState*, const UString&, JSStringFinalizerCallback callback, void* context);
+ friend JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length);
};
JSString* asString(JSValue);
@@ -519,6 +521,19 @@ namespace JSC {
JSGlobalData* globalData = &exec->globalData();
return fixupVPtr(globalData, new (globalData) JSString(globalData, s, callback, context));
}
+
+ inline JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length)
+ {
+ ASSERT(offset <= static_cast<unsigned>(s->length()));
+ ASSERT(length <= static_cast<unsigned>(s->length()));
+ ASSERT(offset + length <= static_cast<unsigned>(s->length()));
+ JSGlobalData* globalData = &exec->globalData();
+ if (!length)
+ return globalData->smallStrings.emptyString(globalData);
+ if (s->isRope())
+ return s->substringFromRope(exec, offset, length);
+ return jsSubstring(globalData, s->m_value, offset, length);
+ }
inline JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
{