Branch: Tag:

2001-02-02

2001-02-02 13:03:15 by Per Hedbor <ph@opera.com>

Optimized

Rev: server/modules/graphics/gbutton.pike:1.76

25:   // must also be aligned left or right.       - constant cvs_version = "$Id: gbutton.pike,v 1.75 2001/01/12 16:16:11 anders Exp $"; + constant cvs_version = "$Id: gbutton.pike,v 1.76 2001/02/02 13:03:15 per Exp $";   constant thread_safe = 1;      #include <module.h>
725:    return button_cache->http_file_answer(f, id);   }    + mapping __stat_cache = ([ ]); + int get_file_stat( string f, RequestID id ) + { +  if( __stat_cache[ f ] ) +  return __stat_cache[ f ];    -  +  call_out( m_delete, 10, __stat_cache, f ); +  return __stat_cache[ f ] = (id->conf->stat_file( f,id ) +  || file_stat( f ) +  || ({ 0,0,0,0 }))[ST_MTIME]; + } +    class ButtonFrame {    inherit RXML.Frame;       array mk_url(RequestID id)    { -  + // int t = gethrtime();    string fi = (args["frame-image"] ||    id->misc->defines["gbutton-frame-image"]);    if( fi )    fi = Roxen.fix_relative( fi, id );       // Harmonize some attribute names to RXML standards... -  args->icon_src = args["icon-src"] || args->icon_src; -  args->icon_data = args["icon-data"] || args->icon_data; -  args->align_icon = args["align-icon"] || args->align_icon; +  args->icon_src = args["icon-src"] || args->icon_src; +  args->icon_data = args["icon-data"] || args->icon_data; +  args->align_icon = args["align-icon"] || args->align_icon;    args->valign_icon = args["valign-icon"] || args->valign_icon;    m_delete(args, "icon-src");    m_delete(args, "icon-data");    m_delete(args, "align-icon");    -  mapping new_args = ([ +  mapping new_args = +  ([    "pagebg" :parse_color(args->pagebgcolor ||    id->misc->defines->theme_bgcolor ||    id->misc->defines->bgcolor ||
786:    "gamma":args["gamma"],    "crop":args["crop"],    ]); -  -  +     if( fi ) -  new_args->stat = (id->conf->stat_file( fi,id ) -  || file_stat( fi ) -  || ({ 0,0,0,0 }))[ST_MTIME]; +  new_args->stat = get_file_stat( fi, id );    -  string fn; -  if( new_args->stat && (fn = id->conf->real_file( fi, id ) ) ) -  Roxen.add_cache_stat_callback( id, fn, new_args->stat ); -  +     new_args->quant = args->quant || 128;    foreach(glob("*-*", indices(args)), string n)    new_args[n] = args[n];    -  +  // if( new_args->stat && (fn = id->conf->real_file( fi, id ) ) ) +  // Roxen.add_cache_stat_callback( id, fn, new_args->stat ); +  +  string fn; + // werror("mkurl took %dµs\n", gethrtime()-t ); +  + // t = gethrtime();    string img_src =    query_absolute_internal_location(id) +    button_cache->store( ({ new_args, content }), id); -  + // werror("argcache->store took %dµs\n", gethrtime()-t );    return ({ img_src, new_args });    }   }