-
Notifications
You must be signed in to change notification settings - Fork 14
Feature reimpl arraybuffer #92
base: master
Are you sure you want to change the base?
Conversation
…ode's buffer. v8::ArrayBuffer can work on an external buffer without owning it. Closes intel#90
@tingshao I've updated the impl of ArrayBuffer, there are a few changes, including a revert of your previous PR which make ArrayBuffer be a persistent member variable of NanXXX wrapper class. The reason of the revert is that we sometimes need to update the buffer length, but with your previous PR, there is no way we can update it since it's cached only once. |
private: | ||
void CopyFrom(const ArrayBufferHelper& rhs) { | ||
if (this != &rhs) { | ||
data_ = rhs.data_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the buffer copy using assign cause multiple free if the mode is internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if external_buffer_
is false
, then there can be double delete problem, unless user explicitly change one object and set its external_buffer
to true
Can there be an automatically approach to avoid this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the const to change the rhs? Seems not compatible with the coding style. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we rename the class to ExternalArrayBuffer
and make it only work in external buffer mode
?
ArrayBuffer
s with ownership of buffer will be treated in other class, to avoid potential issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The choice of whether ExternalArrayBuffer or InternalArrayBuffer is made only in impl code right? I'm ok with that.
No description provided.