Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Disable AsciiSliceExt
Browse files Browse the repository at this point in the history
Seems faster and less buggy?
  • Loading branch information
ry committed Mar 12, 2010
1 parent ca862d7 commit 3d10852
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/node_buffer.cc
Expand Up @@ -77,7 +77,7 @@ static inline void blob_unref(Blob *blob) {
}
}


#if 0
// When someone calls buffer.asciiSlice, data is not copied. Instead V8
// references in the underlying Blob with this ExternalAsciiStringResource.
class AsciiSliceExt: public String::ExternalAsciiStringResource {
Expand All @@ -89,7 +89,7 @@ class AsciiSliceExt: public String::ExternalAsciiStringResource {

assert(start <= end);
length_ = end - start;
assert(length_ <= parent->length());
assert(start + length_ <= parent->length());
data_ = parent->data() + start;
}

Expand All @@ -108,6 +108,7 @@ class AsciiSliceExt: public String::ExternalAsciiStringResource {
size_t length_;
Blob *blob_;
};
#endif


Handle<Value> Buffer::New(const Arguments &args) {
Expand Down Expand Up @@ -174,11 +175,19 @@ Handle<Value> Buffer::AsciiSlice(const Arguments &args) {
HandleScope scope;
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1])

#if 0
AsciiSliceExt *ext = new AsciiSliceExt(parent, start, end);
Local<String> string = String::NewExternal(ext);
// There should be at least two references to the blob now - the parent
// and the slice.
assert(parent->blob_->refs >= 2);
#endif

const char *data = const_cast<char*>(parent->data_ + start);
Local<String> string = String::New(data, end - start);


return scope.Close(string);
}

Expand Down

0 comments on commit 3d10852

Please sign in to comment.