Click here to Skip to main content
15,896,557 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: blind micro optimisation Pin
CodeWomble31-May-22 19:40
CodeWomble31-May-22 19:40 
GeneralRe: blind micro optimisation Pin
Super Lloyd31-May-22 20:12
Super Lloyd31-May-22 20:12 
GeneralRe: blind micro optimisation Pin
dan!sh 31-May-22 21:16
professional dan!sh 31-May-22 21:16 
GeneralRe: blind micro optimisation Pin
lmoelleb31-May-22 23:06
lmoelleb31-May-22 23:06 
GeneralRe: blind micro optimisation Pin
Super Lloyd31-May-22 23:17
Super Lloyd31-May-22 23:17 
GeneralRe: blind micro optimisation Pin
megaadam31-May-22 23:39
professionalmegaadam31-May-22 23:39 
GeneralRe: blind micro optimisation Pin
Richard Deeming1-Jun-22 0:23
mveRichard Deeming1-Jun-22 0:23 
GeneralRe: blind micro optimisation Pin
jsc421-Jun-22 0:27
professionaljsc421-Jun-22 0:27 
An ultra pedantic code reviewer would suggest that
C#
foreach (var item in source)
{
  if (item is A a)
    list.Add(a);
  if (item is B b)
    DoThing(b);
}
could be improved by doing
C#
foreach (var item in source)
{
  if (item is A a)
    list.Add(a);
  else if (item is B b)
    DoThing(b);
}
or
C#
foreach (var item in source)
{
  if (item is B b)
    DoThing(b);
  else if (item is A a)
    list.Add(a);
}
as that would save rechecking found items. This would, however, possibly not give the desired effect if an item could be both an A and B (e.g. if A inherits B, B inherits A, or A / B are interfaces and the item can implement both interfaces).

Of course, you should spent a couple of weeks analysing these two code snippets with multiple copies of sample data to see which one saves the most milliseconds per decade Dead | X| WTF | :WTF:

So, as others have said, ignore the code reviewer and do what makes sense to you.
GeneralRe: blind micro optimisation Pin
Richard Deeming1-Jun-22 0:35
mveRichard Deeming1-Jun-22 0:35 
GeneralRe: blind micro optimisation Pin
PIEBALDconsult1-Jun-22 2:43
mvePIEBALDconsult1-Jun-22 2:43 
GeneralRe: blind micro optimisation Pin
Super Lloyd1-Jun-22 17:33
Super Lloyd1-Jun-22 17:33 
GeneralRe: blind micro optimisation Pin
honey the codewitch1-Jun-22 2:58
mvahoney the codewitch1-Jun-22 2:58 
GeneralRe: blind micro optimisation Pin
Super Lloyd1-Jun-22 17:32
Super Lloyd1-Jun-22 17:32 
GeneralRe: blind micro optimisation Pin
obermd2-Jun-22 3:12
obermd2-Jun-22 3:12 
GeneralRe: blind micro optimisation Pin
honey the codewitch3-Jun-22 3:09
mvahoney the codewitch3-Jun-22 3:09 
GeneralRe: blind micro optimisation Pin
Super Lloyd4-Jun-22 6:21
Super Lloyd4-Jun-22 6:21 
GeneralRe: blind micro optimisation Pin
honey the codewitch4-Jun-22 6:48
mvahoney the codewitch4-Jun-22 6:48 
GeneralRe: blind micro optimisation Pin
obermd1-Jun-22 4:35
obermd1-Jun-22 4:35 
GeneralRe: blind micro optimisation Pin
Rick York1-Jun-22 11:27
mveRick York1-Jun-22 11:27 
GeneralRe: blind micro optimisation Pin
jmaida1-Jun-22 15:06
jmaida1-Jun-22 15:06 
AnswerRe: blind micro optimisation Pin
Saša Ćetković2-Jun-22 4:01
professionalSaša Ćetković2-Jun-22 4:01 
Generalbad joke Pin
jmaida31-May-22 17:35
jmaida31-May-22 17:35 
GeneralRe: bad joke Pin
DerekT-P1-Jun-22 0:52
professionalDerekT-P1-Jun-22 0:52 
GeneralRe: bad joke Pin
jmaida1-Jun-22 8:07
jmaida1-Jun-22 8:07 
GeneralRe: bad joke Pin
DRHuff1-Jun-22 10:20
DRHuff1-Jun-22 10:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.