| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,13 +87,13 @@ void AsyncHooks::ResetPromiseHooks(Local<Function> init, | |||
| 87 | 87 | js_promise_hooks_[3].Reset(env()->isolate(), resolve); | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | - Local<Array> AsyncHooks::GetPromiseHooks(Isolate* isolate) { | ||
| 91 | - std::vector<Local<Value>> values; | ||
| 90 | + Local<Array> AsyncHooks::GetPromiseHooks(Isolate* isolate) const { | ||
| 91 | + v8::LocalVector<Value> values(isolate, js_promise_hooks_.size()); | ||
| 92 | 92 | for (size_t i = 0; i < js_promise_hooks_.size(); ++i) { | |
| 93 | 93 | if (js_promise_hooks_[i].IsEmpty()) { | |
| 94 | - values.push_back(Undefined(isolate)); | ||
| 94 | + values[i] = Undefined(isolate); | ||
| 95 | 95 | } else { | |
| 96 | - values.push_back(js_promise_hooks_[i].Get(isolate)); | ||
| 96 | + values[i] = js_promise_hooks_[i].Get(isolate); | ||
| 97 | 97 | } | |
| 98 | 98 | } | |
| 99 | 99 | return Array::New(isolate, values.data(), values.size()); | |
@@ -236,13 +236,10 @@ void Environment::TrackContext(Local<Context> context) { | |||
| 236 | 236 | ||
| 237 | 237 | void Environment::UntrackContext(Local<Context> context) { | |
| 238 | 238 | HandleScope handle_scope(isolate_); | |
| 239 | - contexts_.erase(std::remove_if(contexts_.begin(), | ||
| 240 | - contexts_.end(), | ||
| 241 | - [&](auto&& el) { return el.IsEmpty(); }), | ||
| 242 | - contexts_.end()); | ||
| 239 | + std::erase_if(contexts_, [&](auto&& el) { return el.IsEmpty(); }); | ||
| 243 | 240 | for (auto it = contexts_.begin(); it != contexts_.end(); it++) { | |
| 244 | - Local<Context> saved_context = PersistentToLocal::Weak(isolate_, *it); | ||
| 245 | - if (saved_context == context) { | ||
| 241 | + if (Local<Context> saved_context = PersistentToLocal::Weak(isolate_, *it); | ||
| 242 | + saved_context == context) { | ||
| 246 | 243 | it->Reset(); | |
| 247 | 244 | contexts_.erase(it); | |
| 248 | 245 | break; | |
@@ -351,9 +348,11 @@ IsolateDataSerializeInfo IsolateData::Serialize(SnapshotCreator* creator) { | |||
| 351 | 348 | #undef VS | |
| 352 | 349 | #undef VP | |
| 353 | 350 | ||
| 354 | - for (size_t i = 0; i < AsyncWrap::PROVIDERS_LENGTH; i++) | ||
| 351 | + info.primitive_values.reserve(info.primitive_values.size() + | ||
| 352 | + AsyncWrap::PROVIDERS_LENGTH); | ||
| 353 | + for (size_t i = 0; i < AsyncWrap::PROVIDERS_LENGTH; i++) { | ||
| 355 | 354 | info.primitive_values.push_back(creator->AddData(async_wrap_provider(i))); | |
| 356 | - | ||
| 355 | + } | ||
| 357 | 356 | uint32_t id = 0; | |
| 358 | 357 | #define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate) | |
| 359 | 358 | #define V(PropertyName, TypeName) \ | |
@@ -375,7 +374,7 @@ IsolateDataSerializeInfo IsolateData::Serialize(SnapshotCreator* creator) { | |||
| 375 | 374 | void IsolateData::DeserializeProperties(const IsolateDataSerializeInfo* info) { | |
| 376 | 375 | size_t i = 0; | |
| 377 | 376 | ||
| 378 | - v8::Isolate::Scope isolate_scope(isolate_); | ||
| 377 | + Isolate::Scope isolate_scope(isolate_); | ||
| 379 | 378 | HandleScope handle_scope(isolate_); | |
| 380 | 379 | ||
| 381 | 380 | if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) { | |
@@ -732,9 +731,8 @@ void Environment::TryLoadAddon( | |||
| 732 | 731 | std::string Environment::GetCwd(const std::string& exec_path) { | |
| 733 | 732 | char cwd[PATH_MAX_BYTES]; | |
| 734 | 733 | size_t size = PATH_MAX_BYTES; | |
| 735 | - const int err = uv_cwd(cwd, &size); | ||
| 736 | 734 | ||
| 737 | - if (err == 0) { | ||
| 735 | + if (uv_cwd(cwd, &size) == 0) { | ||
| 738 | 736 | CHECK_GT(size, 0); | |
| 739 | 737 | return cwd; | |
| 740 | 738 | } | |
@@ -780,7 +778,7 @@ std::string Environment::GetExecPath(const std::vector<std::string>& argv) { | |||
| 780 | 778 | std::string exec_path; | |
| 781 | 779 | if (uv_exepath(exec_path_buf, &exec_path_len) == 0) { | |
| 782 | 780 | exec_path = std::string(exec_path_buf, exec_path_len); | |
| 783 | - } else if (argv.size() > 0) { | ||
| 781 | + } else if (!argv.empty()) { | ||
| 784 | 782 | exec_path = argv[0]; | |
| 785 | 783 | } | |
| 786 | 784 | ||
@@ -1250,7 +1248,8 @@ void Environment::StartProfilerIdleNotifier() { | |||
| 1250 | 1248 | } | |
| 1251 | 1249 | ||
| 1252 | 1250 | void Environment::PrintSyncTrace() const { | |
| 1253 | - if (!trace_sync_io_) return; | ||
| 1251 | + if (!trace_sync_io_) [[likely]] | ||
| 1252 | + return; | ||
| 1254 | 1253 | ||
| 1255 | 1254 | HandleScope handle_scope(isolate()); | |
| 1256 | 1255 | ||
@@ -1325,7 +1324,7 @@ void Environment::AtExit(void (*cb)(void* arg), void* arg) { | |||
| 1325 | 1324 | at_exit_functions_.push_front(ExitCallback{cb, arg}); | |
| 1326 | 1325 | } | |
| 1327 | 1326 | ||
| 1328 | - Maybe<bool> Environment::CheckUnsettledTopLevelAwait() { | ||
| 1327 | + Maybe<bool> Environment::CheckUnsettledTopLevelAwait() const { | ||
| 1329 | 1328 | HandleScope scope(isolate_); | |
| 1330 | 1329 | Local<Context> ctx = context(); | |
| 1331 | 1330 | Local<Value> value; | |
@@ -1527,7 +1526,7 @@ void Environment::RunTimers(uv_timer_t* handle) { | |||
| 1527 | 1526 | int64_t expiry_ms = | |
| 1528 | 1527 | ret.ToLocalChecked()->IntegerValue(env->context()).FromJust(); | |
| 1529 | 1528 | ||
| 1530 | - uv_handle_t* h = reinterpret_cast<uv_handle_t*>(handle); | ||
| 1529 | + auto* h = reinterpret_cast<uv_handle_t*>(handle); | ||
| 1531 | 1530 | ||
| 1532 | 1531 | if (expiry_ms != 0) { | |
| 1533 | 1532 | int64_t duration_ms = | |
@@ -1593,8 +1592,7 @@ Local<Value> Environment::GetNow() { | |||
| 1593 | 1592 | uint64_t now = GetNowUint64(); | |
| 1594 | 1593 | if (now <= 0xffffffff) | |
| 1595 | 1594 | return Integer::NewFromUnsigned(isolate(), static_cast<uint32_t>(now)); | |
| 1596 | - else | ||
| 1597 | - return Number::New(isolate(), static_cast<double>(now)); | ||
| 1595 | + return Number::New(isolate(), static_cast<double>(now)); | ||
| 1598 | 1596 | } | |
| 1599 | 1597 | ||
| 1600 | 1598 | void CollectExceptionInfo(Environment* env, | |
@@ -1653,8 +1651,8 @@ void Environment::CollectUVExceptionInfo(Local<Value> object, | |||
| 1653 | 1651 | message = uv_strerror(errorno); | |
| 1654 | 1652 | } | |
| 1655 | 1653 | ||
| 1656 | - node::CollectExceptionInfo(this, obj, errorno, err_string, | ||
| 1657 | - syscall, message, path, dest); | ||
| 1654 | + CollectExceptionInfo( | ||
| 1655 | + this, obj, errorno, err_string, syscall, message, path, dest); | ||
| 1658 | 1656 | } | |
| 1659 | 1657 | ||
| 1660 | 1658 | ImmediateInfo::ImmediateInfo(Isolate* isolate, const SerializeInfo* info) | |
@@ -1984,7 +1982,7 @@ void Environment::BuildEmbedderGraph(Isolate* isolate, | |||
| 1984 | 1982 | EmbedderGraph* graph, | |
| 1985 | 1983 | void* data) { | |
| 1986 | 1984 | MemoryTracker tracker(isolate, graph); | |
| 1987 | - Environment* env = static_cast<Environment*>(data); | ||
| 1985 | + auto* env = static_cast<Environment*>(data); | ||
| 1988 | 1986 | // Start traversing embedder objects from the root Environment object. | |
| 1989 | 1987 | tracker.Track(env); | |
| 1990 | 1988 | } | |
@@ -2046,7 +2044,7 @@ void Environment::TracePromises(PromiseHookType type, | |||
| 2046 | 2044 | size_t Environment::NearHeapLimitCallback(void* data, | |
| 2047 | 2045 | size_t current_heap_limit, | |
| 2048 | 2046 | size_t initial_heap_limit) { | |
| 2049 | - Environment* env = static_cast<Environment*>(data); | ||
| 2047 | + auto* env = static_cast<Environment*>(data); | ||
| 2050 | 2048 | ||
| 2051 | 2049 | Debug(env, | |
| 2052 | 2050 | DebugCategory::DIAGNOSTICS, | |
@@ -2092,8 +2090,8 @@ size_t Environment::NearHeapLimitCallback(void* data, | |||
| 2092 | 2090 | DebugCategory::DIAGNOSTICS, | |
| 2093 | 2091 | "Estimated available memory=%" PRIu64 ", " | |
| 2094 | 2092 | "estimated overhead=%" PRIu64 "\n", | |
| 2095 | - static_cast<uint64_t>(available), | ||
| 2096 | - static_cast<uint64_t>(estimated_overhead)); | ||
| 2093 | + available, | ||
| 2094 | + estimated_overhead); | ||
| 2097 | 2095 | ||
| 2098 | 2096 | // This might be hit when the snapshot is being taken in another | |
| 2099 | 2097 | // NearHeapLimitCallback invocation. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -333,7 +333,7 @@ class AsyncHooks : public MemoryRetainer { | |||
| 333 | 333 | v8::Local<v8::Function> resolve); | |
| 334 | 334 | // Used for testing since V8 doesn't provide API for retrieving configured | |
| 335 | 335 | // JS promise hooks. | |
| 336 | - v8::Local<v8::Array> GetPromiseHooks(v8::Isolate* isolate); | ||
| 336 | + v8::Local<v8::Array> GetPromiseHooks(v8::Isolate* isolate) const; | ||
| 337 | 337 | inline v8::Local<v8::String> provider_string(int idx); | |
| 338 | 338 | ||
| 339 | 339 | inline void no_force_checks(); | |
@@ -852,7 +852,7 @@ class Environment final : public MemoryRetainer { | |||
| 852 | 852 | void AtExit(void (*cb)(void* arg), void* arg); | |
| 853 | 853 | void RunAtExitCallbacks(); | |
| 854 | 854 | ||
| 855 | - v8::Maybe<bool> CheckUnsettledTopLevelAwait(); | ||
| 855 | + v8::Maybe<bool> CheckUnsettledTopLevelAwait() const; | ||
| 856 | 856 | void RunWeakRefCleanup(); | |
| 857 | 857 | ||
| 858 | 858 | v8::MaybeLocal<v8::Value> RunSnapshotSerializeCallback() const; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments