Skip to content

Pass by reference when null is not expected #4546

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

Merged
merged 1 commit into from
Dec 8, 2019

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Dec 8, 2019

No description provided.

@sharwell sharwell requested a review from a team as a code owner December 8, 2019 00:33
@sharwell sharwell mentioned this pull request Dec 8, 2019
@codecov
Copy link

codecov bot commented Dec 8, 2019

Codecov Report

Merging #4546 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4546      +/-   ##
==========================================
+ Coverage    75.1%   75.11%   +<.01%     
==========================================
  Files         908      908              
  Lines      160260   160260              
  Branches    17259    17259              
==========================================
+ Hits       120369   120379      +10     
+ Misses      35070    35067       -3     
+ Partials     4821     4814       -7
Flag Coverage Δ
#Debug 75.11% <ø> (ø) ⬆️
#production 70.51% <ø> (ø) ⬆️
#test 90.26% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/Microsoft.ML.AutoML/Sweepers/Parameters.cs 78.81% <0%> (-4.24%) ⬇️
...soft.ML.Data/DataLoadSave/Text/TextLoaderCursor.cs 84.7% <0%> (-0.41%) ⬇️
...ML.Transforms/Text/StopWordsRemovingTransformer.cs 86.1% <0%> (-0.16%) ⬇️
src/Microsoft.ML.Maml/MAML.cs 26.21% <0%> (+1.45%) ⬆️
...rosoft.ML.AutoML/ColumnInference/TextFileSample.cs 62.25% <0%> (+2.64%) ⬆️
....ML.AutoML/PipelineSuggesters/PipelineSuggester.cs 86.55% <0%> (+6.72%) ⬆️
...c/Microsoft.ML.FastTree/Utils/ThreadTaskManager.cs 100% <0%> (+20.51%) ⬆️

Copy link
Member

@codemzs codemzs left a comment

Choose a reason for hiding this comment

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

:shipit:

@codemzs
Copy link
Member

codemzs commented Dec 8, 2019

Thanks but can you please the rationale for passing by reference instead of pointers?

@sharwell
Copy link
Member Author

sharwell commented Dec 8, 2019

The method uses the object without checking it for null, so it's clear that it never expects a null pointer as input. References are an idiomatic way of expressing intent in C++ that the input is not expected to be null, and is used by the method but not stored by the method for later use (i.e. the scope of use extends to the return from the method, and no further).

@sharwell sharwell merged commit a4b4660 into dotnet:master Dec 8, 2019
@sharwell sharwell deleted the pass-by-ref branch December 8, 2019 17:42
@ghost ghost locked as resolved and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants