• + 2 comments

    Efficient code is code that generates the least amount of machine instructions or unrolls loops not what looks efficient in higher level language. Take both samples of code and compile them and then look at the assembly generated. When you write code with a lot of nested ternary operators the compiler cannot perform its optimizations correctly. So,

    if (x == y){
        ...
    }else if(y == z){
      ...  
    }else if(z > w){
      ...
    }else{
      ...
    }
    

    will optimize better than

    (x==y)?...:(y==z)?...:(z > w)?...:...