-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Refactor/code optimization #12187
Refactor/code optimization #12187
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1150,7 +1150,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) { | |
node::Utf8Value hostname(env->isolate(), args[1]); | ||
|
||
int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0; | ||
int family; | ||
int family = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems confusing for the same reason as @mscdex’ comment below … :/ |
||
|
||
switch (args[2]->Int32Value()) { | ||
case 0: | ||
|
@@ -1263,7 +1263,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) { | |
ares_addr_node* servers = new ares_addr_node[len]; | ||
ares_addr_node* last = nullptr; | ||
|
||
int err; | ||
int err = 0; | ||
|
||
for (uint32_t i = 0; i < len; i++) { | ||
CHECK(arr->Get(i)->IsArray()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ void JSStream::New(const FunctionCallbackInfo<Value>& args) { | |
// normal function. | ||
CHECK(args.IsConstructCall()); | ||
Environment* env = Environment::GetCurrent(args); | ||
JSStream* wrap; | ||
JSStream* wrap = NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't necessary, either the variable will already be assigned below or the process aborts because of an unreachable condition. Also, |
||
|
||
if (args.Length() == 0) { | ||
wrap = new JSStream(env, args.This(), nullptr); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ inline void ClientHelloParser::Reset() { | |
extension_offset_ = 0; | ||
session_size_ = 0; | ||
session_id_ = nullptr; | ||
tls_ticket_size_ = -1; | ||
tls_ticket_size_ = static_cast<uint16_t>(-1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 , this does increase readability a bit |
||
tls_ticket_ = nullptr; | ||
servername_size_ = 0; | ||
servername_ = nullptr; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,11 +224,11 @@ static void After(uv_fs_t *req) { | |
break; | ||
|
||
case UV_FS_OPEN: | ||
argv[1] = Integer::New(env->isolate(), req->result); | ||
argv[1] = Integer::New(env->isolate(), static_cast<int32_t>(req->result)); //possible los of data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: |
||
break; | ||
|
||
case UV_FS_WRITE: | ||
argv[1] = Integer::New(env->isolate(), req->result); | ||
argv[1] = Integer::New(env->isolate(), static_cast<int32_t>(req->result)); | ||
break; | ||
|
||
case UV_FS_MKDTEMP: | ||
|
@@ -281,7 +281,7 @@ static void After(uv_fs_t *req) { | |
|
||
case UV_FS_READ: | ||
// Buffer interface | ||
argv[1] = Integer::New(env->isolate(), req->result); | ||
argv[1] = Integer::New(env->isolate(), static_cast<int32_t>(req->result)); | ||
break; | ||
|
||
case UV_FS_SCANDIR: | ||
|
@@ -442,19 +442,19 @@ static void Close(const FunctionCallbackInfo<Value>& args) { | |
|
||
|
||
void FillStatsArray(double* fields, const uv_stat_t* s) { | ||
fields[0] = s->st_dev; | ||
fields[1] = s->st_mode; | ||
fields[2] = s->st_nlink; | ||
fields[3] = s->st_uid; | ||
fields[4] = s->st_gid; | ||
fields[5] = s->st_rdev; | ||
fields[0] = static_cast<double>(s->st_dev); | ||
fields[1] = static_cast<double>(s->st_mode); | ||
fields[2] = static_cast<double>(s->st_nlink); | ||
fields[3] = static_cast<double>(s->st_uid); | ||
fields[4] = static_cast<double>(s->st_gid); | ||
fields[5] = static_cast<double>(s->st_rdev); | ||
#if defined(__POSIX__) | ||
fields[6] = s->st_blksize; | ||
#else | ||
fields[6] = -1; | ||
#endif | ||
fields[7] = s->st_ino; | ||
fields[8] = s->st_size; | ||
fields[7] = static_cast<double>(s->st_ino); | ||
fields[8] = static_cast<double>(s->st_size); | ||
#if defined(__POSIX__) | ||
fields[9] = s->st_blocks; | ||
#else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend against changing these things here, there would be quite a few conflicts with #11883