I think the best way to learn efficient coding, at least in control programs, is to study assembly language. It gives good insight as to how compilers work. For example in your program, the line "PORTD=Column[x];" makes the compiler build code to calculate the table offset from variable X then do a look-up, possibly switching banks and almost certainly using 'hidden' variables as well. If you coded as "PORTD.B0 = 0; PORTD.B1 = 1;" it would produce only two instructions "bcf PORTD,0" and "bsf PORTD,1" which would run faster and use far les memory.
There are no rules about how you do it but understanding assembly language will reveal the most efficient algoriths for simple operations. When it comes to high level math routines, the assembly language becomes difficult to follow so it's better to just assume the C routines work as the manual states.
Brian.