From 3d10852c3368b492583f16e266374710ebdd54c3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 12 Mar 2010 12:15:25 -0800 Subject: [PATCH] Disable AsciiSliceExt Seems faster and less buggy? --- src/node_buffer.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 70820dd49b3..975cbfe322f 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -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 { @@ -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; } @@ -108,6 +108,7 @@ class AsciiSliceExt: public String::ExternalAsciiStringResource { size_t length_; Blob *blob_; }; +#endif Handle Buffer::New(const Arguments &args) { @@ -174,11 +175,19 @@ Handle Buffer::AsciiSlice(const Arguments &args) { HandleScope scope; Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) + +#if 0 AsciiSliceExt *ext = new AsciiSliceExt(parent, start, end); Local 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(parent->data_ + start); + Local string = String::New(data, end - start); + + return scope.Close(string); }