summaryrefslogtreecommitdiff
path: root/src/timer_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-07 21:50:41 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-08-09 11:44:50 +0200
commitf674b09f40d22915e15b6968aafc5d25ac8178a2 (patch)
treeb227505171dffe126aefde9855b4db2c765e70e1 /src/timer_wrap.cc
parentc0e70354dbf7dcc76e69dd1973451eb10a2ebdfe (diff)
downloadandroid-node-v8-f674b09f40d22915e15b6968aafc5d25ac8178a2.tar.gz
android-node-v8-f674b09f40d22915e15b6968aafc5d25ac8178a2.tar.bz2
android-node-v8-f674b09f40d22915e15b6968aafc5d25ac8178a2.zip
src: use v8::String::NewFrom*() functions
* Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r--src/timer_wrap.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc
index 3ba1f1975c..1f62db9867 100644
--- a/src/timer_wrap.cc
+++ b/src/timer_wrap.cc
@@ -44,7 +44,7 @@ class TimerWrap : public HandleWrap {
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(String::NewSymbol("Timer"));
+ constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"));
NODE_SET_METHOD(constructor, "now", Now);
@@ -58,9 +58,10 @@ class TimerWrap : public HandleWrap {
NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat);
NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again);
- ontimeout_sym = String::New("ontimeout");
+ ontimeout_sym = FIXED_ONE_BYTE_STRING(node_isolate, "ontimeout");
- target->Set(String::NewSymbol("Timer"), constructor->GetFunction());
+ target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"),
+ constructor->GetFunction());
}
private: