From f150d569159537f478b78c8132e055a4d3fbb44e Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Thu, 21 Mar 2013 09:26:23 -0700 Subject: [PATCH] src: write ascii strings using WriteOneByte WriteAscii will be deprecated soon from v8, and performance has regressed. The v8 team recommended using WriteOneByte instead. --- src/node.cc | 5 ++++- src/node_buffer.cc | 10 +++++----- src/stream_wrap.cc | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/node.cc b/src/node.cc index 629c84c688..44c9e9bea2 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1212,7 +1212,10 @@ ssize_t DecodeWrite(char *buf, } if (encoding == ASCII) { - str->WriteAscii(buf, 0, buflen, String::HINT_MANY_WRITES_EXPECTED); + str->WriteOneByte(reinterpret_cast(buf), + 0, + buflen, + String::HINT_MANY_WRITES_EXPECTED); return buflen; } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index e629ecd44d..6a74b6a682 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -749,11 +749,11 @@ Handle Buffer::AsciiWrite(const Arguments &args) { char *p = buffer->data_ + offset; - int written = s->WriteAscii(p, - 0, - max_length, - (String::HINT_MANY_WRITES_EXPECTED | - String::NO_NULL_TERMINATION)); + int written = s->WriteOneByte(reinterpret_cast(p), + 0, + max_length, + (String::HINT_MANY_WRITES_EXPECTED | + String::NO_NULL_TERMINATION)); constructor_template->GetFunction()->Set(chars_written_sym, Integer::New(written, node_isolate)); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index ade0a79531..01fc8de894 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -392,7 +392,7 @@ Handle StreamWrap::WriteStringImpl(const Arguments& args) { size_t data_size; switch (encoding) { case kAscii: - data_size = string->WriteAscii(data, 0, -1, + data_size = string->WriteOneByte(reinterpret_cast(data), 0, -1, String::NO_NULL_TERMINATION | String::HINT_MANY_WRITES_EXPECTED); break;