summaryrefslogtreecommitdiff
path: root/src/timer_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-15 19:23:36 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-08-15 19:33:34 +0200
commit0aa13357d67be84ea9021be43497dca7c91cabee (patch)
treea894b9cb4d792d10f193c3f09cefb7f579c6aea1 /src/timer_wrap.cc
parent7a3f7780dc9eed1391b389dec82849137ac9d5f5 (diff)
downloadandroid-node-v8-0aa13357d67be84ea9021be43497dca7c91cabee.tar.gz
android-node-v8-0aa13357d67be84ea9021be43497dca7c91cabee.tar.bz2
android-node-v8-0aa13357d67be84ea9021be43497dca7c91cabee.zip
timers: dispatch ontimeout callback by array index
Achieve a minor speed-up by looking up the timeout callback on the timer object by using an array index rather than a named property. Gives a performance boost of about 1% on the misc/timers benchmarks.
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r--src/timer_wrap.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc
index 8abe33eb25..1f84de53e5 100644
--- a/src/timer_wrap.cc
+++ b/src/timer_wrap.cc
@@ -22,6 +22,8 @@
#include "node.h"
#include "handle_wrap.h"
+#include <stdint.h>
+
namespace node {
using v8::Function;
@@ -35,7 +37,7 @@ using v8::Object;
using v8::String;
using v8::Value;
-static Cached<String> ontimeout_sym;
+const uint32_t kOnTimeout = 0;
class TimerWrap : public HandleWrap {
public:
@@ -45,6 +47,8 @@ class TimerWrap : public HandleWrap {
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"));
+ constructor->Set(FIXED_ONE_BYTE_STRING(node_isolate, "kOnTimeout"),
+ Integer::New(kOnTimeout, node_isolate));
NODE_SET_METHOD(constructor, "now", Now);
@@ -58,8 +62,6 @@ class TimerWrap : public HandleWrap {
NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat);
NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again);
- ontimeout_sym = FIXED_ONE_BYTE_STRING(node_isolate, "ontimeout");
-
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"),
constructor->GetFunction());
}
@@ -138,7 +140,7 @@ class TimerWrap : public HandleWrap {
assert(wrap);
Local<Value> argv[1] = { Integer::New(status, node_isolate) };
- MakeCallback(wrap->object(), ontimeout_sym, ARRAY_SIZE(argv), argv);
+ MakeCallback(wrap->object(), kOnTimeout, ARRAY_SIZE(argv), argv);
}
static void Now(const FunctionCallbackInfo<Value>& args) {