-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
src: refactor code to remove duplicate logic #34553
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
Conversation
|
What do you mean by "library name" ? |
|
@mscdex |
|
I don’t see any particular reason to avoid the names of standard library classes. We’re never importing items from the |
|
@addaleax Agree with you but as a convention should we be using keyword names as an identifier? I wrote the patch because if someone reads it they might think why we are using this variable name when it is a keyword defined in one the libraries provided. As we avoid using |
|
I'd prefer readability over potential keyword conflicts as well - especially considering the std namespace can be extended as C++ grows and keywords like |
|
@joyeecheung Agree with you but my intention behind the changes is similar to usage of |
|
@yashLadha I don't think there's any particular convention in native code variable naming, it's just my personal opinion that verbose names are better than names like |
fd4ef08 to
468ef6c
Compare
|
@joyeecheung @addaleax when I looked in the complete file itself found that this logic is being duplicated at several places, so converted the logic to use a single inline function so that code doesn't get duplicated. |
bdaf4df to
6187fbe
Compare
|
Also no performance degradation as well |
addaleax
left a comment
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.
Are the unrelated formatting changes here done by clang-format?
|
Yes @addaleax linter did that. |
src/node_process_methods.cc
Outdated
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.
It would be better to name it like get_fields_array_buffer_from_first_argument, or accept an argument specifying the index of the argument array, otherwise this new convention makes the code less easier to grok IMO.
6187fbe to
a4fd1eb
Compare
tniessen
left a comment
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.
Lots of unrelated whitespace changes.
src/node_process_methods.cc
Outdated
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.
Do we want these kind of changes?
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.
This was done by the clang-formatter 😅 not intentional
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.
Can you try reformatting the code and make sure you set CLANG_FORMAT_START to where this branch branches off from the master, so that it does not format irrelevant changes? For example since this PR only contains 3 commits you can also try CLANG_FORMAT_START=HEAD~3 make format-cpp
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.
@joyeecheung Output from the command
❯ CLANG_FORMAT_START=HEAD~3 make format-cpp
Formatting C++ diff from HEAD~3..
clang-format did not modify any files
I think what i can do is basically reset to master and do the changes only and do not format the code. In that way those unnecessary changes won't be there.
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.
Removed the formatting changes.
a4fd1eb to
770d2bb
Compare
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic.
770d2bb to
18d5b99
Compare
|
Landed in 4b0308a...8656ab4 |
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic. PR-URL: #34553 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic. PR-URL: #34553 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic. PR-URL: #34553 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic. PR-URL: #34553 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
We were fetching the buffer from the float array to send out the response in js land, however that logic is being duplicated in node_process.h. Now they will be using an inline to fetch the array buffers and making it more generic. PR-URL: #34553 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes