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

src: use pass by reference in module_wrap.cc #15591

Closed
wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Sep 24, 2017

This commit changes several pass by value arguments to pass by
reference. This change was motivated by the following Coverity
reports:

** CID 177292: Performance inefficiencies (PASS_BY_VALUE)
/src/module_wrap.cc: 326 in node::loader::::
check_file(node::url::URL, bool, bool)()

** CID 177293: Performance inefficiencies (PASS_BY_VALUE)
/src/module_wrap.cc: 352 in node::loader::::
resolve_extensions(node::url::URL, bool)()

*** CID 177290: Performance inefficiencies (PASS_BY_VALUE)
/src/module_wrap.cc: 368 in node::loader::::
resolve_index(node::url::URL)()

*** CID 177289: Performance inefficiencies (PASS_BY_VALUE)
/src/module_wrap.cc: 371 in node::loader::::
resolve_main(node::url::URL)()

*** CID 177291: Performance inefficiencies (PASS_BY_VALUE)
/src/module_wrap.cc: 430 in node::loader::::
resolve_directory(node::url::URL, bool)()

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src

This commit changes several pass by value arguments to pass by
reference. This change was motivated by the following Coverity
reports:

** CID 177292:  Performance inefficiencies  (PASS_BY_VALUE)
/src/module_wrap.cc: 326 in node::loader::<unnamed>::
    check_file(node::url::URL, bool, bool)()

** CID 177293:  Performance inefficiencies  (PASS_BY_VALUE)
/src/module_wrap.cc: 352 in node::loader::<unnamed>::
    resolve_extensions(node::url::URL, bool)()

*** CID 177290:  Performance inefficiencies  (PASS_BY_VALUE)
/src/module_wrap.cc: 368 in node::loader::<unnamed>::
    resolve_index(node::url::URL)()

*** CID 177289:  Performance inefficiencies  (PASS_BY_VALUE)
/src/module_wrap.cc: 371 in node::loader::<unnamed>::
    resolve_main(node::url::URL)()

*** CID 177291:  Performance inefficiencies  (PASS_BY_VALUE)
/src/module_wrap.cc: 430 in node::loader::<unnamed>::
    resolve_directory(node::url::URL, bool)()
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Sep 24, 2017
@@ -323,12 +323,12 @@ struct file_check {
bool failed = true;
uv_file file = -1;
};
inline const struct file_check check_file(URL search,
inline const struct file_check check_file(URL* search,
Copy link
Member

Choose a reason for hiding this comment

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

I think none of the methods here in question actually modify the incoming parameter? In that case, just switching URLconst URL& would be nicer…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I'll update.

@addaleax
Copy link
Member

@cjihrig I’d suggest closing this in favour of @sam-github’s #15615

@cjihrig cjihrig closed this Sep 25, 2017
@cjihrig cjihrig deleted the pass-by-ref branch September 25, 2017 19:00
@sam-github
Copy link
Contributor

@cjihrig sorry Colin, I looked to see if someone had covered this, but missed your PR. I think I was looking too hard for URL in the subject.

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.

4 participants