Browse Source

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 <trev.norris@gmail.com>
v0.11.14-release
Ben Noordhuis 10 years ago
committed by Trevor Norris
parent
commit
06526a2a93
  1. 17
      src/env-inl.h
  2. 2
      src/env.h
  3. 9
      src/node.cc

17
src/env-inl.h

@ -207,23 +207,6 @@ inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) {
context->GetAlignedPointerFromEmbedderData(kContextEmbedderDataIndex)); 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<v8::Context> context) {
if (context.IsEmpty()) {
return NULL;
} else {
return GetCurrent(context);
}
}
inline Environment::Environment(v8::Local<v8::Context> context) inline Environment::Environment(v8::Local<v8::Context> context)
: isolate_(context->GetIsolate()), : isolate_(context->GetIsolate()),
isolate_data_(IsolateData::GetOrCreate(context->GetIsolate())), isolate_data_(IsolateData::GetOrCreate(context->GetIsolate())),

2
src/env.h

@ -359,8 +359,6 @@ class Environment {
static inline Environment* GetCurrent(v8::Isolate* isolate); static inline Environment* GetCurrent(v8::Isolate* isolate);
static inline Environment* GetCurrent(v8::Local<v8::Context> context); static inline Environment* GetCurrent(v8::Local<v8::Context> context);
static inline Environment* GetCurrentChecked(v8::Isolate* isolate);
static inline Environment* GetCurrentChecked(v8::Local<v8::Context> context);
// See CreateEnvironment() in src/node.cc. // See CreateEnvironment() in src/node.cc.
static inline Environment* New(v8::Local<v8::Context> context); static inline Environment* New(v8::Local<v8::Context> context);

9
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); fprintf(stderr, "Debugger listening on port %d\n", debug_port);
fflush(stderr); fflush(stderr);
Environment* env = Environment::GetCurrentChecked(isolate); if (isolate == NULL)
if (env == NULL)
return; // Still starting up. return; // Still starting up.
Local<Context> context = isolate->GetCurrentContext();
if (context.IsEmpty())
return; // Still starting up.
Environment* env = Environment::GetCurrent(context);
// Assign environment to the debugger's context // Assign environment to the debugger's context
env->AssignToContext(v8::Debug::GetDebugContext()); env->AssignToContext(v8::Debug::GetDebugContext());
@ -3624,7 +3627,7 @@ int Start(int argc, char** argv) {
env->AssignToContext(v8::Debug::GetDebugContext()); env->AssignToContext(v8::Debug::GetDebugContext());
} }
// This Context::Scope is here so EnableDebug() can look up the current // 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 // TODO(bnoordhuis) Reorder the debugger initialization logic so it can
// be removed. // be removed.
{ {

Loading…
Cancel
Save