Branch: Tag:

2014-05-22

2014-05-22 16:49:17 by Per Hedbor <ph@opera.com>

Binary size: push_constant_text -> push_text when not time-critical.

Especially in error handling, and code that does a lot of other string
operations anyway the speed gain is not wort the 100+ bytes code size
of each instance of push_constant_text

This saves about 20K of code size (main pike binary), while not really
changing the speed much.

push_constant_text that seemed to be in at least pseudo-time-critical
code was kept as they were.

On a related note, push_constant_text(":") four times in a row creates
four different string variables, for obvious reasons.

Some of the remaining push_constant_text really should have a
module/file local string variable, even though that is more bothersome
to create.

It might be nice to have this in .cmod files automatically.

665:    pop_n_elems(args);    if (i<1)    { -  push_constant_text("#"); /* stupid */ +  push_text("#"); /* stupid */    return;    }    else if (i!=sizeof(COLORTYPE)*2)
810:   /* case 'c': */   /* case 'd': */    case 't': -  push_constant_text("Image.Color.Color"); +  push_text("Image.Color.Color");    return;    case 'O':    if (!THIS->name) try_find_name(THIS);    if (THIS->name==no_name)    { -  push_constant_text("Image.Color(\""); +  push_text("Image.Color(\"");    if (prec)    {    push_int(prec);
824:    }    else    image_color_hex(0); -  push_constant_text("\")"); +  push_text("\")");    f_add(3);    return;    }    else    { -  push_constant_text("Image.Color."); +  push_text("Image.Color.");    ref_push_string(THIS->name);    f_add(2);    return;
1423:    "Bad arguments to Image.Color->guess()\n");       f_lower_case(1); -  push_constant_text(" "); +  push_text(" ");    o_subtract();       stack_dup();
1435:    return;    }    pop_stack(); -  push_constant_text("#"); +  push_text("#");    stack_swap();    f_add(2);   
1693:    image_get_color(1);    else    { -  push_constant_text("#"); +  push_text("#");    stack_swap();    f_add(2);    image_get_color(1);