summaryrefslogtreecommitdiff
path: root/src/node_file.cc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-09-04 20:59:24 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-09-09 11:03:48 -0700
commit1cf538a60a5306a554d3cfad412003578a96d5e5 (patch)
tree3f9456697ea92f82b760806c0c1f9a9ca36affd1 /src/node_file.cc
parent2dda6be7991fc6809eedca4dc51935a178c63745 (diff)
downloadnode-new-1cf538a60a5306a554d3cfad412003578a96d5e5.tar.gz
Work to get C++ fast buffers. incomplete
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 18c3704642..56876493b4 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -626,24 +626,26 @@ static Handle<Value> Write(const Arguments& args) {
return ThrowException(Exception::Error(
String::New("Second argument needs to be a buffer")));
}
-
- Buffer * buffer = ObjectWrap::Unwrap<Buffer>(args[1]->ToObject());
+
+ Local<Object> buffer_obj = args[1]->ToObject();
+ char *buffer_data = Buffer::Data(buffer_obj);
+ size_t buffer_length = Buffer::Length(buffer_obj);
size_t off = args[2]->Int32Value();
- if (off >= buffer->length()) {
+ if (off >= buffer_length) {
return ThrowException(Exception::Error(
String::New("Offset is out of bounds")));
}
ssize_t len = args[3]->Int32Value();
- if (off + len > buffer->length()) {
+ if (off + len > buffer_length) {
return ThrowException(Exception::Error(
String::New("Length is extends beyond buffer")));
}
off_t pos = GET_OFFSET(args[4]);
- char * buf = (char*)buffer->data() + off;
+ char * buf = (char*)buffer_data + off;
Local<Value> cb = args[5];
if (cb->IsFunction()) {
@@ -688,23 +690,25 @@ static Handle<Value> Read(const Arguments& args) {
String::New("Second argument needs to be a buffer")));
}
- Buffer * buffer = ObjectWrap::Unwrap<Buffer>(args[1]->ToObject());
+ Local<Object> buffer_obj = args[1]->ToObject();
+ char *buffer_data = Buffer::Data(buffer_obj);
+ size_t buffer_length = Buffer::Length(buffer_obj);
size_t off = args[2]->Int32Value();
- if (off >= buffer->length()) {
+ if (off >= buffer_length) {
return ThrowException(Exception::Error(
String::New("Offset is out of bounds")));
}
len = args[3]->Int32Value();
- if (off + len > buffer->length()) {
+ if (off + len > buffer_length) {
return ThrowException(Exception::Error(
String::New("Length is extends beyond buffer")));
}
pos = GET_OFFSET(args[4]);
- buf = (char*)buffer->data() + off;
+ buf = buffer_data + off;
cb = args[5];