Changeset 1057 in svn


Ignore:
Timestamp:
2012-07-27T07:52:12Z (3 years ago)
Author:
Xuefer
Message:

cacher: reduce branch checking for counter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1051 r1057  
    389389}
    390390/* }}} */
    391 static void xc_counters_inc(time_t *curtime, zend_uint *curslot, time_t period, zend_ulong *counters, zend_uint count TSRMLS_DC) /* {{{ */
    392 {
    393     time_t n = XG(request_time) / period;
     391static inline void xc_counters_inc(time_t *curtime, zend_uint *curslot, time_t interval, zend_ulong *counters, zend_uint count TSRMLS_DC) /* {{{ */
     392{
     393    time_t n = XG(request_time) / interval;
    394394    if (*curtime != n) {
    395395        zend_uint target_slot = n % count;
    396         if (n - *curtime > period) {
    397             memset(counters, 0, sizeof(counters[0]) * count);
    398         }
    399         else {
    400             zend_uint slot;
    401             for (slot = advance_wrapped(*curslot, count);
    402                     slot != target_slot;
    403                     slot = advance_wrapped(slot, count)) {
    404                 counters[slot] = 0;
    405             }
    406             counters[target_slot] = 0;
    407         }
     396        zend_uint slot;
     397        for (slot = advance_wrapped(*curslot, count);
     398                slot != target_slot;
     399                slot = advance_wrapped(slot, count)) {
     400            counters[slot] = 0;
     401        }
     402        counters[target_slot] = 0;
    408403        *curtime = n;
    409404        *curslot = target_slot;
     
    412407}
    413408/* }}} */
    414 static void xc_cache_hit_unlocked(xc_cache_t *cache TSRMLS_DC) /* {{{ */
     409static inline void xc_cache_hit_unlocked(xc_cache_t *cache TSRMLS_DC) /* {{{ */
    415410{
    416411    cache->hits ++;
     
    423418
    424419    xc_counters_inc(&cache->hits_by_second_cur_time
    425             , &cache->hits_by_second_cur_slot
    426             , 1
     420            , &cache->hits_by_second_cur_slot, 1
    427421            , cache->hits_by_second
    428422            , sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0])
Note: See TracChangeset for help on using the changeset viewer.