Make check in GetExternalString a runtime check instead of ASSERT.

This will allow us to remove the separate call to IsExternal() from our
chrome client code, speeding up the combination.

Review URL: http://codereview.chromium.org/113035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1887 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5cf3897f
......@@ -827,14 +827,14 @@ class V8EXPORT String : public Primitive {
};
/**
* Get the ExternalStringResource for an external string. Only
* valid if IsExternal() returns true.
* Get the ExternalStringResource for an external string. Returns
* NULL if IsExternal() doesn't return true.
*/
ExternalStringResource* GetExternalStringResource() const;
/**
* Get the ExternalAsciiStringResource for an external ascii string.
* Only valid if IsExternalAscii() returns true.
* Returns NULL if IsExternalAscii() doesn't return true.
*/
ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
......
......@@ -2355,9 +2355,12 @@ v8::String::ExternalStringResource*
v8::String::GetExternalStringResource() const {
EnsureInitialized("v8::String::GetExternalStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalTwoByteString());
void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
return reinterpret_cast<ExternalStringResource*>(resource);
if (i::StringShape(*str).IsExternalTwoByte()) {
void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
return reinterpret_cast<ExternalStringResource*>(resource);
} else {
return NULL;
}
}
......@@ -2365,9 +2368,12 @@ v8::String::ExternalAsciiStringResource*
v8::String::GetExternalAsciiStringResource() const {
EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalAsciiString());
void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource();
return reinterpret_cast<ExternalAsciiStringResource*>(resource);
if (i::StringShape(*str).IsExternalAscii()) {
void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource();
return reinterpret_cast<ExternalAsciiStringResource*>(resource);
} else {
return NULL;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment