Disable AsciiSliceExt
Seems faster and less buggy?
This commit is contained in:
parent
ca862d75de
commit
3d10852c33
@ -77,7 +77,7 @@ static inline void blob_unref(Blob *blob) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// When someone calls buffer.asciiSlice, data is not copied. Instead V8
|
// When someone calls buffer.asciiSlice, data is not copied. Instead V8
|
||||||
// references in the underlying Blob with this ExternalAsciiStringResource.
|
// references in the underlying Blob with this ExternalAsciiStringResource.
|
||||||
class AsciiSliceExt: public String::ExternalAsciiStringResource {
|
class AsciiSliceExt: public String::ExternalAsciiStringResource {
|
||||||
@ -89,7 +89,7 @@ class AsciiSliceExt: public String::ExternalAsciiStringResource {
|
|||||||
|
|
||||||
assert(start <= end);
|
assert(start <= end);
|
||||||
length_ = end - start;
|
length_ = end - start;
|
||||||
assert(length_ <= parent->length());
|
assert(start + length_ <= parent->length());
|
||||||
data_ = parent->data() + start;
|
data_ = parent->data() + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +108,7 @@ class AsciiSliceExt: public String::ExternalAsciiStringResource {
|
|||||||
size_t length_;
|
size_t length_;
|
||||||
Blob *blob_;
|
Blob *blob_;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Handle<Value> Buffer::New(const Arguments &args) {
|
Handle<Value> Buffer::New(const Arguments &args) {
|
||||||
@ -174,11 +175,19 @@ Handle<Value> Buffer::AsciiSlice(const Arguments &args) {
|
|||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
|
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
|
||||||
SLICE_ARGS(args[0], args[1])
|
SLICE_ARGS(args[0], args[1])
|
||||||
|
|
||||||
|
#if 0
|
||||||
AsciiSliceExt *ext = new AsciiSliceExt(parent, start, end);
|
AsciiSliceExt *ext = new AsciiSliceExt(parent, start, end);
|
||||||
Local<String> string = String::NewExternal(ext);
|
Local<String> string = String::NewExternal(ext);
|
||||||
// There should be at least two references to the blob now - the parent
|
// There should be at least two references to the blob now - the parent
|
||||||
// and the slice.
|
// and the slice.
|
||||||
assert(parent->blob_->refs >= 2);
|
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);
|
return scope.Close(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user