From 06526a2a93794a973b01514ce43fcd40b911e143 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 5 Sep 2014 17:33:28 +0200 Subject: src: remove Environment::GetCurrentChecked() There is only one call site that uses it and that can do the checks itself. Removes ~15 lines of code. Reviewed-by: Trevor Norris --- src/env-inl.h | 17 ----------------- src/env.h | 2 -- src/node.cc | 9 ++++++--- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 90fc77c62..4bc5eb098 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -207,23 +207,6 @@ inline Environment* Environment::GetCurrent(v8::Local context) { context->GetAlignedPointerFromEmbedderData(kContextEmbedderDataIndex)); } -inline Environment* Environment::GetCurrentChecked(v8::Isolate* isolate) { - if (isolate == NULL) { - return NULL; - } else { - return GetCurrentChecked(isolate->GetCurrentContext()); - } -} - -inline Environment* Environment::GetCurrentChecked( - v8::Local context) { - if (context.IsEmpty()) { - return NULL; - } else { - return GetCurrent(context); - } -} - inline Environment::Environment(v8::Local context) : isolate_(context->GetIsolate()), isolate_data_(IsolateData::GetOrCreate(context->GetIsolate())), diff --git a/src/env.h b/src/env.h index 4a26dd112..7fe132ce6 100644 --- a/src/env.h +++ b/src/env.h @@ -359,8 +359,6 @@ class Environment { static inline Environment* GetCurrent(v8::Isolate* isolate); static inline Environment* GetCurrent(v8::Local context); - static inline Environment* GetCurrentChecked(v8::Isolate* isolate); - static inline Environment* GetCurrentChecked(v8::Local context); // See CreateEnvironment() in src/node.cc. static inline Environment* New(v8::Local context); diff --git a/src/node.cc b/src/node.cc index d2f9f8b8d..76d650336 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3102,9 +3102,12 @@ static void EnableDebug(Isolate* isolate, bool wait_connect) { fprintf(stderr, "Debugger listening on port %d\n", debug_port); fflush(stderr); - Environment* env = Environment::GetCurrentChecked(isolate); - if (env == NULL) + if (isolate == NULL) return; // Still starting up. + Local context = isolate->GetCurrentContext(); + if (context.IsEmpty()) + return; // Still starting up. + Environment* env = Environment::GetCurrent(context); // Assign environment to the debugger's context env->AssignToContext(v8::Debug::GetDebugContext()); @@ -3624,7 +3627,7 @@ int Start(int argc, char** argv) { env->AssignToContext(v8::Debug::GetDebugContext()); } // This Context::Scope is here so EnableDebug() can look up the current - // environment with Environment::GetCurrentChecked(). + // environment with Environment::GetCurrent(). // TODO(bnoordhuis) Reorder the debugger initialization logic so it can // be removed. { -- cgit v1.2.3