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

Input

Name: Anonymous 2009-03-31 13:05

I've got two methods of initializing large quantities of variables. Which piece of code should be used? Not only performance wise but also for readability.


void menu_draw_init(){
    path_buffer =  malloc(MENU_PATH_COUNT);
    u8 c;

    for(c=0;c<MENU_PATH_COUNT;c++)
        if(c)
            path_buffer[c] = &buffer_sub;
        else
            path_buffer[c] = &buffer_main;
}

--OR--


void menu_draw_init(){
    path_buffer =  malloc(MENU_PATH_COUNT);

    path_buffer[0] = &buffer_main;
    path_buffer[1] = &buffer_sub;
    path_buffer[2] = &buffer_sub;
    path_buffer[3] = &buffer_sub;
            ...
    path_buffer[81] = &buffer_sub;

}

So which piece of code is better to use?

Name: Anonymous 2009-03-31 13:07

The first with loop unrolling. Idiot.

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