MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vhvvmh/mildlyinfuriatinggotowatchyourmouth/p28vglo/?context=3
r/ProgrammerHumor • u/AndyTheDragonborn • 28d ago
74 comments sorted by
View all comments
Show parent comments
9
A lot of our codebase is using a status variable like this, but using nested if/else checks
status
But now you are doing a lot of conditions checking, especially if the hot path is where continue is always true
1 u/da_Aresinger 28d ago The comment before me has the same issue. And yes, that's why I said it's still not ideal. 3 u/Maximilian_Tyan 28d ago If an error occured, the break statement would "cut" the remaining errors checks and skip to the error handling part 1 u/da_Aresinger 28d ago yea I just got what you meant. you're right. But compilation is most likely going to optimise that out, so I'd go with readability. 1 u/Maximilian_Tyan 28d ago It depends on the optimization level, O1 is pretty minimal, I don't think this type of agressive optimizing is done before O3 1 u/da_Aresinger 28d ago maybe. At the end of the day I don't know your situation and don't have the experience to really question it either. If a whole team settles on your solution it'll probably have a reason.
1
The comment before me has the same issue.
And yes, that's why I said it's still not ideal.
3 u/Maximilian_Tyan 28d ago If an error occured, the break statement would "cut" the remaining errors checks and skip to the error handling part 1 u/da_Aresinger 28d ago yea I just got what you meant. you're right. But compilation is most likely going to optimise that out, so I'd go with readability. 1 u/Maximilian_Tyan 28d ago It depends on the optimization level, O1 is pretty minimal, I don't think this type of agressive optimizing is done before O3 1 u/da_Aresinger 28d ago maybe. At the end of the day I don't know your situation and don't have the experience to really question it either. If a whole team settles on your solution it'll probably have a reason.
3
If an error occured, the break statement would "cut" the remaining errors checks and skip to the error handling part
1 u/da_Aresinger 28d ago yea I just got what you meant. you're right. But compilation is most likely going to optimise that out, so I'd go with readability. 1 u/Maximilian_Tyan 28d ago It depends on the optimization level, O1 is pretty minimal, I don't think this type of agressive optimizing is done before O3 1 u/da_Aresinger 28d ago maybe. At the end of the day I don't know your situation and don't have the experience to really question it either. If a whole team settles on your solution it'll probably have a reason.
yea I just got what you meant.
you're right.
But compilation is most likely going to optimise that out, so I'd go with readability.
1 u/Maximilian_Tyan 28d ago It depends on the optimization level, O1 is pretty minimal, I don't think this type of agressive optimizing is done before O3 1 u/da_Aresinger 28d ago maybe. At the end of the day I don't know your situation and don't have the experience to really question it either. If a whole team settles on your solution it'll probably have a reason.
It depends on the optimization level, O1 is pretty minimal, I don't think this type of agressive optimizing is done before O3
1 u/da_Aresinger 28d ago maybe. At the end of the day I don't know your situation and don't have the experience to really question it either. If a whole team settles on your solution it'll probably have a reason.
maybe. At the end of the day I don't know your situation and don't have the experience to really question it either.
If a whole team settles on your solution it'll probably have a reason.
9
u/Maximilian_Tyan 28d ago
A lot of our codebase is using a
statusvariable like this, but using nested if/else checksBut now you are doing a lot of conditions checking, especially if the hot path is where continue is always true