Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

src: write ascii strings using WriteOneByte

WriteAscii will be deprecated soon from v8, and performance has
regressed. The v8 team recommended using WriteOneByte instead.
  • Loading branch information...
commit f150d569159537f478b78c8132e055a4d3fbb44e 1 parent 40b1c9a
@trevnorris trevnorris authored indutny committed
Showing with 10 additions and 7 deletions.
  1. +4 −1 src/node.cc
  2. +5 −5 src/node_buffer.cc
  3. +1 −1  src/stream_wrap.cc
View
5 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<uint8_t*>(buf),
+ 0,
+ buflen,
+ String::HINT_MANY_WRITES_EXPECTED);
return buflen;
}
View
10 src/node_buffer.cc
@@ -749,11 +749,11 @@ Handle<Value> 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<uint8_t*>(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));
View
2  src/stream_wrap.cc
@@ -392,7 +392,7 @@ Handle<Value> 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<uint8_t*>(data), 0, -1,
String::NO_NULL_TERMINATION | String::HINT_MANY_WRITES_EXPECTED);
break;
Please sign in to comment.
Something went wrong with that request. Please try again.