| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 47105573fda7f763ff1abc0f31d98887703272f5..0d01fcc75e2a9e14c506acb82533027e956b1534 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -1136,13 +1136,18 @@ ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
|
| ScriptData* ScriptData::New(const char* data, int length) {
|
| // Return an empty ScriptData if the length is obviously invalid.
|
| if (length % sizeof(unsigned) != 0) {
|
| - return new i::ScriptDataImpl(i::Vector<unsigned>());
|
| + return new i::ScriptDataImpl();
|
| }
|
|
|
| // Copy the data to ensure it is properly aligned.
|
| int deserialized_data_length = length / sizeof(unsigned);
|
| + // If aligned, don't create a copy of the data.
|
| + if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
|
| + return new i::ScriptDataImpl(data, length);
|
| + }
|
| + // Copy the data to align it.
|
| unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
|
| - memcpy(deserialized_data, data, length);
|
| + i::MemCopy(deserialized_data, data, length);
|
|
|
| return new i::ScriptDataImpl(
|
| i::Vector<unsigned>(deserialized_data, deserialized_data_length));
|
|
|