Branch: Tag:


2014-05-22 16:49:17 by Per Hedbor <>

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.

1445:    int n=0;    pop_n_elems(args);    -  push_constant_text("xsize"); push_int(THIS->xsize); n++; -  push_constant_text("ysize"); push_int(THIS->ysize); n++; -  push_constant_text("image"); image_layer_image(0); n++; -  push_constant_text("alpha"); image_layer_alpha(0); n++; -  push_constant_text("xoffset"); push_int(THIS->xoffs); n++; -  push_constant_text("yoffset"); push_int(THIS->yoffs); n++; -  push_constant_text("alpha_value"); push_float(THIS->alpha_value); n++; -  push_constant_text("fill"); image_layer_fill(0); n++; -  push_constant_text("fill_alpha"); image_layer_fill_alpha(0); n++; -  push_constant_text("tiled"); push_int(THIS->tiled); n++; -  push_constant_text("mode"); image_layer_mode(0); n++; +  push_text("xsize"); push_int(THIS->xsize); n++; +  push_text("ysize"); push_int(THIS->ysize); n++; +  push_text("image"); image_layer_image(0); n++; +  push_text("alpha"); image_layer_alpha(0); n++; +  push_text("xoffset"); push_int(THIS->xoffs); n++; +  push_text("yoffset"); push_int(THIS->yoffs); n++; +  push_text("alpha_value"); push_float(THIS->alpha_value); n++; +  push_text("fill"); image_layer_fill(0); n++; +  push_text("fill_alpha"); image_layer_fill_alpha(0); n++; +  push_text("tiled"); push_int(THIS->tiled); n++; +  push_text("mode"); image_layer_mode(0); n++;       f_aggregate_mapping(n*2);   
3271:    switch( x )    {    case 't': -  push_constant_text("Image.Layer"); +  push_text("Image.Layer");    return;    case 'O': -  push_constant_text( "Image.Layer(%O i=%O a=%O)" ); +  push_text( "Image.Layer(%O i=%O a=%O)" );    image_layer_mode(0);    if( THIS->image ) ref_push_object( THIS->image ); else push_int( 0 );    if( THIS->alpha ) ref_push_object( THIS->alpha ); else push_int( 0 );