On Tue, Jul 8, 2014 at 11:01 AM, <[email protected]> wrote: > https://codereview.chromium.org/373713006/diff/1/src/ > serialize.cc#newcode1844 > src/serialize.cc:1844: return new ScriptData(Vector<unsigned>(raw_data, > raw_length), true); > On 2014/07/07 15:20:01, vogelheim wrote: > >> This copies the bulk of the data twice: Once in CopyBytes, and then in >> ScriptData(..., true). Maybe instead of forcing a copy there could be >> > some sort > >> of 'move'-constructor for ScriptData. >> > > (Since there's probably more changes to ScriptData coming, maybe just >> > leave it > >> in for now, though.) >> > > Nope. ScriptData::New does the copying. The constructor merely sets the > owns_store_ flag, which is what we want here.
Nack. What I meant: The resulting vector contains some 40-ish byte header plus a (usually much larger) blob of serialized code. The larger code blob is copied just 2 lines above this, by explicitly calling CopyBytes. Then the ScriptData::New(.., true) copies the whole data again, this time with header. That's two copies, and one of them is unnecessary. One way to avoid the 2nd copy would be to allocate the data underlying the Vector right there, copying the blob data and header into it, and then having a ScriptData::New-variant that assumes ownership of the data passed in. -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
