summaryrefslogtreecommitdiff
path: root/src/fs_event_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/fs_event_wrap.cc
parentc0e70354dbf7dcc76e69dd1973451eb10a2ebdfe (diff)
downloadnode-new-f674b09f40d22915e15b6968aafc5d25ac8178a2.tar.gz
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/fs_event_wrap.cc')
-rw-r--r--src/fs_event_wrap.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc
index b8d24c0d35..8c10ccac9d 100644
--- a/src/fs_event_wrap.cc
+++ b/src/fs_event_wrap.cc
@@ -75,16 +75,16 @@ void FSEventWrap::Initialize(Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->InstanceTemplate()->SetInternalFieldCount(1);
- t->SetClassName(String::NewSymbol("FSEvent"));
+ t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "FSEvent"));
NODE_SET_PROTOTYPE_METHOD(t, "start", Start);
NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
- target->Set(String::New("FSEvent"), t->GetFunction());
+ target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "FSEvent"), t->GetFunction());
- change_sym = String::New("change");
- onchange_sym = String::New("onchange");
- rename_sym = String::New("rename");
+ change_sym = FIXED_ONE_BYTE_STRING(node_isolate, "change");
+ onchange_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onchange");
+ rename_sym = FIXED_ONE_BYTE_STRING(node_isolate, "rename");
}
@@ -161,7 +161,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
};
if (filename != NULL) {
- argv[2] = String::New(filename);
+ argv[2] = OneByteString(node_isolate, filename);
}
MakeCallback(wrap->object(), onchange_sym, ARRAY_SIZE(argv), argv);