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.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Option to default to show icon in tab, hide tabicon or make icon in tab monochrome. #15948
Option to default to show icon in tab, hide tabicon or make icon in tab monochrome. #15948
Changes from 1 commit
0f3c340
193fb60
83bafbd
03efa7a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
IconStyle is an enum type; is it useful to pass that by
const &
?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.
By passing it const& you indicate that it is a read-only type and it should not copy the value.
You can resolve the comment if you have no further questions.
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.
What's wrong with copying the value though? It's 32-bit so nowadays smaller than a pointer. There are other methods that take
bool
parameters by value.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 agree with @KalleOlaviNiemitalo.
const&
is most useful when passing RAII types to avoid making costly copies. An integer is much much cheaper to pass by-value.(It can also be useful under certain circumstances when passing >8 bytes on the Windows x64 ABI due to poor MSVC optimizations, but I'm sure those few cycles are fairly irrelevant in most circumstances.)
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.
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 don't think it's fair to use other instances of this as proof that it isn't a mistake. Otherwise what does this code imply?
terminal/src/types/ModifierKeyState.cpp
Lines 100 to 137 in 9b70a40
It turns a regular bitset into a
std::unordered_set<>
just to then test whether a given bit is set. It creates an entire hashmap instance just to do the equivalent ofa & b != 0
. It would be pretty terrific if this implied that binary operators are bad!Passing primitive types by reference is a minuscule issue, so it's not really something I'm bothered by and I'll approve this PR regardless. But I believe if it came to a debate about this, that I could win it with fairly solid arguments.
Especially since statements like "it should not copy the value" are factually wrong. Passing parameters by value doesn't necessarily create a copy. Primitive types aren't classes after all.
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 will not argue that you would have more solid arguments, but entering a code base, I found it better to do as already written, as to the arguments it is wrong or not, existing examples were already written with
const&
, so I found it better to copy the style.My arguments are to the understanding of my knowledge and thank you for providing me with more information. My question would then be more along the lines of whether should we fix the existing code, or should we make it more clear that we do not need it, as now we are changing style from what is already written. I enjoy code that follows the same style.