Permalink
Browse files

Remove ifdefs specific to Node 0.3

  • Loading branch information...
1 parent 7903607 commit 69687d0255e9d6af95060e600efef1118809aa5c @pietern pietern committed Aug 28, 2012
Showing with 0 additions and 28 deletions.
  1. +0 −17 reader.cc
  2. +0 −3 reader.h
  3. +0 −8 test/reader.js
View
@@ -80,7 +80,6 @@ Reader::Reader(bool return_buffers) :
reader->fn = &v8ReplyFunctions;
reader->privdata = this;
-#if NODE_VERSION_AT_LEAST(0,3,0)
if (return_buffers) {
Local<Object> global = Context::GetCurrent()->Global();
Local<Value> bv = global->Get(String::NewSymbol("Buffer"));
@@ -94,7 +93,6 @@ Reader::Reader(bool return_buffers) :
Buffer *b = Buffer::New(buffer_pool_length);
buffer_pool = Persistent<Object>::New(b->handle_);
}
-#endif
}
Reader::~Reader() {
@@ -105,24 +103,17 @@ Reader::~Reader() {
* the caller (Reader::Get) and we don't have to the pay the overhead. */
Local<Value> Reader::createString(char *str, size_t len) {
if (return_buffers) {
-#if NODE_VERSION_AT_LEAST(0,3,0)
if (len > buffer_pool_length) {
Buffer *b = Buffer::New(str,len);
return Local<Value>::New(b->handle_);
} else {
return createBufferFromPool(str,len);
}
-#else
- Buffer *b = Buffer::New(len);
- memcpy(b->data(),str,len);
- return Local<Value>::New(b->handle_);
-#endif
} else {
return String::New(str,len);
}
}
-#if NODE_VERSION_AT_LEAST(0,3,0)
Local<Value> Reader::createBufferFromPool(char *str, size_t len) {
HandleScope scope;
Local<Value> argv[3];
@@ -145,7 +136,6 @@ Local<Value> Reader::createBufferFromPool(char *str, size_t len) {
buffer_pool_offset += len;
return scope.Close(instance);
}
-#endif
Handle<Value> Reader::New(const Arguments& args) {
HandleScope scope;
@@ -185,14 +175,8 @@ Handle<Value> Reader::Feed(const Arguments &args) {
char *data;
size_t length;
-#if NODE_VERSION_AT_LEAST(0,3,0)
data = Buffer::Data(buffer_object);
length = Buffer::Length(buffer_object);
-#else
- Buffer *buffer = ObjectWrap::Unwrap<Buffer>(buffer_object);
- data = buffer->data();
- length = buffer->length();
-#endif
/* Can't handle OOM for now. */
assert(redisReaderFeed(r->reader, data, length) == REDIS_OK);
@@ -235,4 +219,3 @@ Handle<Value> Reader::Get(const Arguments &args) {
return scope.Close(reply);
}
-
View
@@ -40,15 +40,12 @@ class Reader : ObjectWrap {
* replies. This defaults to false, so strings are returned by default. */
bool return_buffers;
-#if NODE_VERSION_AT_LEAST(0,3,0)
/* Use a buffer pool like the fast buffers. */
Local<Value> createBufferFromPool(char *str, size_t len);
Persistent<Function> buffer_fn;
Persistent<Object> buffer_pool;
size_t buffer_pool_length;
size_t buffer_pool_offset;
-#endif
-
};
};
View
@@ -1,14 +1,6 @@
var assert = require("assert"),
hiredis = require("../hiredis");
-/* Monkey-patch Buffer.isBuffer on 0.3.1 */
-if (process.versions.node == "0.3.1") {
- var SlowBuffer = process.binding('buffer').SlowBuffer;
- Buffer.isBuffer = function isBuffer(b) {
- return b instanceof Buffer || b instanceof SlowBuffer;
- };
-}
-
var passed = 0;
var failed = 0;

0 comments on commit 69687d0

Please sign in to comment.