| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac2bce0 commit c8175fc
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,12 +36,26 @@ inline void Environment::IsolateData::Put() { | |||
| 36 | 36 | } | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | + // Create string properties as internalized one byte strings. | ||
| 40 | + // | ||
| 41 | + // Internalized because it makes property lookups a little faster and because | ||
| 42 | + // the string is created in the old space straight away. It's going to end up | ||
| 43 | + // in the old space sooner or later anyway but now it doesn't go through | ||
| 44 | + // v8::Eternal's new space handling first. | ||
| 45 | + // | ||
| 46 | + // One byte because our strings are ASCII and we can safely skip V8's UTF-8 | ||
| 47 | + // decoding step. It's a one-time cost, but why pay it when you don't have to? | ||
| 39 | 48 | inline Environment::IsolateData::IsolateData(v8::Isolate* isolate, | |
| 40 | 49 | uv_loop_t* loop) | |
| 41 | 50 | : event_loop_(loop), | |
| 42 | 51 | isolate_(isolate), | |
| 43 | 52 | #define V(PropertyName, StringValue) \ | |
| 44 | - PropertyName ## _(isolate, FIXED_ONE_BYTE_STRING(isolate, StringValue)), | ||
| 53 | + PropertyName ## _(isolate, \ | ||
| 54 | + v8::String::NewFromOneByte( \ | ||
| 55 | + isolate, \ | ||
| 56 | + reinterpret_cast<const uint8_t*>(StringValue), \ | ||
| 57 | + v8::NewStringType::kInternalized, \ | ||
| 58 | + sizeof(StringValue) - 1).ToLocalChecked()), | ||
| 45 | 59 | PER_ISOLATE_STRING_PROPERTIES(V) | |
| 46 | 60 | #undef V | |
| 47 | 61 | ref_count_(0) {} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ namespace node { | |||
| 39 | 39 | #endif | |
| 40 | 40 | ||
| 41 | 41 | // Strings are per-isolate primitives but Environment proxies them | |
| 42 | - // for the sake of convenience. | ||
| 42 | + // for the sake of convenience. Strings should be ASCII-only. | ||
| 43 | 43 | #define PER_ISOLATE_STRING_PROPERTIES(V) \ | |
| 44 | 44 | V(address_string, "address") \ | |
| 45 | 45 | V(args_string, "args") \ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments