Reviewers: Lasse Reichstein, Description: Add api call to determine whether a string can be externalized.
Please review this at http://codereview.chromium.org/164393 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M include/v8.h M src/api.cc Index: include/v8.h =================================================================== --- include/v8.h (revision 2663) +++ include/v8.h (working copy) @@ -901,6 +901,11 @@ */ bool MakeExternal(ExternalAsciiStringResource* resource); + /** + * Returns true if this string can be made external. + */ + bool CanMakeExternal(); + /** Creates an undetectable string from the supplied ascii or utf-8 data.*/ static Local<String> NewUndetectable(const char* data, int length = -1); Index: src/api.cc =================================================================== --- src/api.cc (revision 2663) +++ src/api.cc (working copy) @@ -3037,6 +3037,14 @@ } +bool v8::String::CanMakeExternal() { + if (IsDeadCheck("v8::String::CanMakeExternal()")) return false; + i::Handle <i::String> obj = Utils::OpenHandle(this); + int size = obj->Size(); // Byte size of the original string. + return (size >= i::ExternalString::kSize) && !obj->IsExternalString(); +} + + Local<v8::Object> v8::Object::New() { EnsureInitialized("v8::Object::New()"); LOG_API("Object::New"); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
