Monday 15 June 2015

language agnostic - if statement with or without negation -


Obviously, these two samples get the same thing

Perhaps there is a silly question, But today I started thinking about it.

Edit: Uses an example string but it can be anything , and there is nothing to do with any string comparison of my question etc.

  if (some == 'some') {return "something is up"; } Return;   

versus

  if (some! = 'Some') {return; } Returns "Something's Up";  

If you guess how anyone will trigger on average and how your specific CPU handles For example, if you know that your CPU will always predict that if the branch will proceed in the statement, and you expect that the maximum is not the same, then the first choice:

  If (some == true) {return true; } Return;   

The second demonstration that CPU branch launchers are rarely simple and are now adaptive (see "Saturated Counter") but hopefully this gives you some insight

: Extra:

For two of the comments: When the CPU reaches the assembly, they will be all right. As much as you do, nothing really changes.

No comments:

Post a Comment