Perfect your code
With built-in code review tools, GitHub makes it easy to raise the quality bar before you ship. Join the 31 million developers who've merged over 200 million pull requests.
Sign up for free See pricing for teams and enterprisessrc: lazily load internalBinding('uv') and build the errmap lazily #25143
Conversation
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
C++
errors
libuv
util
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
|
cc @addaleax |
addaleax
approved these changes
Dec 19, 2018
|
Btw, I’ve also thought about creating a static array from the macro here, instead of generating the full code for each entry… that might make things a bit easier as well? |
src/uv.cc Outdated
This comment has been minimized.
This comment has been minimized.
I don't think I follow..what do you mean by creating a static array? |
This comment has been minimized.
This comment has been minimized.
|
@joyeecheung This might not compile because I wrote it here in Github, but I think you get the idea: static const struct {
int value;
const char* name;
const char* message;
} errors[] = {
#define V(name, msg) { UV_##name, #name, msg },
UV_ERRNO_MAP(V)
#undef V
{ 0, nullptr, nullptr }
};
for (const auto* error = errors; error->name != nullptr; error++) {
Local<Value> arr[] = {
OneByteString(isolate, error->name),
OneByteString(isolate, error->msg)
};
if (err_map->Set(context,
Integer::New(isolate, error->value),
Array::New(isolate, arr, arraysize(arr))).IsEmpty()) {
return;
}
}
The major advantage would probably be that the code isn’t several kilobytes large in this case. No strong feelings about it, though :) |
danbev
approved these changes
Dec 20, 2018
joyeecheung
added
author ready
and removed
author ready
labels
Dec 20, 2018
jasnell
approved these changes
Dec 20, 2018
BridgeAR
approved these changes
Dec 27, 2018
joyeecheung
added some commits
Dec 19, 2018
joyeecheung
force-pushed the
joyeecheung:uv-lazy
branch
from
6b72c60
to
0226fe1
Dec 28, 2018
This comment has been minimized.
This comment has been minimized.
joyeecheung
added
the
author ready
label
Dec 29, 2018
This comment has been minimized.
This comment has been minimized.
|
Landed in c66c073 |
joyeecheung
closed this
Dec 29, 2018
joyeecheung
added a commit
that referenced
this pull request
Dec 29, 2018
targos
added a commit
that referenced
this pull request
Jan 1, 2019
refack
added a commit
to refack/node
that referenced
this pull request
Jan 14, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
joyeecheung commentedDec 19, 2018
This removes the
internalBinding('uv')call from the normalbootstrap for now, and avoids building
errmapby default whichexpands to a lot of calls into V8.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes