Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contextify: use assert instead of if #3125

Closed
wants to merge 2 commits into from
Closed

contextify: use assert instead of if #3125

wants to merge 2 commits into from

Conversation

obastemur
Copy link
Contributor

I was walking through the vm changes and saw this particular if check is interesting. In case ctx is empty it's going to fail later anyways.

So, instead of putting an if check there;

option a - use assert
option b - do nothing

Considering the developer wanted to make sure ctx is not empty, assert option looked more convenient.

I was walking through the vm changes and saw this particular `if` check interesting. In case `ctx` is empty it's going to fail later anyways. 
So, instead of putting an `if` check there;

option a - use assert 
option b - do nothing

Considering the developer wanted to make sure `ctx` is not empty, `assert` option looked more convenient.
@brendanashworth brendanashworth added the c++ Issues and PRs that require attention from people who are familiar with C++. label Sep 30, 2015
if (!ctx.IsEmpty())
ctx->SetSecurityToken(env->context()->GetSecurityToken());

assert(!ctx.IsEmpty());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use CHECK(...) here?

@obastemur
Copy link
Contributor Author

Can you use CHECK(...) here?

Sure. done.

bnoordhuis pushed a commit that referenced this pull request Oct 1, 2015
I was walking through the vm changes and saw this particular `if` check
interesting. In case `ctx` is empty it's going to fail later anyways.
So, instead of putting an `if` check there;

option a - use CHECK
option b - do nothing

Considering the developer wanted to make sure `ctx` is not empty,
`CHECK` option looked more convenient.

PR-URL: #3125
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@bnoordhuis
Copy link
Member

Landed in e83499a, thanks.

Tangential aside: I went over the implementation of Context::New() today and I don't think we'll ever actually hit that CHECK. V8 will sooner abort with an OOM error than return an empty Local<Context>. Oh wel..

@bnoordhuis bnoordhuis closed this Oct 1, 2015
rvagg pushed a commit that referenced this pull request Oct 2, 2015
I was walking through the vm changes and saw this particular `if` check
interesting. In case `ctx` is empty it's going to fail later anyways.
So, instead of putting an `if` check there;

option a - use CHECK
option b - do nothing

Considering the developer wanted to make sure `ctx` is not empty,
`CHECK` option looked more convenient.

PR-URL: #3125
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@rvagg rvagg mentioned this pull request Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants