summaryrefslogtreecommitdiff
path: root/src/handle_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/handle_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/handle_wrap.cc')
-rw-r--r--src/handle_wrap.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
index 1eb0dc5216..ce6ac5c5bf 100644
--- a/src/handle_wrap.cc
+++ b/src/handle_wrap.cc
@@ -76,7 +76,9 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
wrap->handle__ = NULL;
if (args[0]->IsFunction()) {
- if (close_sym.IsEmpty() == true) close_sym = String::New("close");
+ if (close_sym.IsEmpty() == true) {
+ close_sym = FIXED_ONE_BYTE_STRING(node_isolate, "close");
+ }
wrap->object()->Set(close_sym, args[0]);
wrap->flags_ |= kCloseCallback;
}