Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegance vs. Performance

Name: Anonymous 2011-05-27 4:11

So /prog/, what would you choose between these two snippets of C code...


int *arr[3];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;


or...


int i;
int *arr[3];
for (i = 0; i < 3; i++)
  arr[i] = i+1;


The second one is more elegant, but requires more operations.

Name: Anonymous 2011-05-27 16:01

>>27,29

I must share >>28 sentiment here, the optimal C solution has been posted, and it wasn't the assembly code. Again you're unable to properly generate an abstraction, C can do things processors are unable to do in the same amount of lines (if we count one instruction as one line), the assembly code posted in this thread gives a general idea what processors are able to do, they can move bits between memory and registers. I'm sure the whole point >>13 was making is that the difference is small when compiled to assembly, so the most readable and modifiable solution is the optimal one.

However, you are still stuck at an infantile level of communication, sticking to worthless insults, you also seem to lack basic reading comprehension. You probably have some brain deficiency, or you just lack general intelligence. Either way I'd recommend you think a little more before you post, or perhaps leave this place altogether, you don't seem to be contributing with anything interesting and you're incapable of listening to anyone that is superior to you.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List