Ignore:
Timestamp:
Oct 4, 2012, 6:15:28 AM (12 years ago)
Author:
rvelices
Message:

php optimizations:

  • use faster [] operator instead of array_push
  • if tags are grouped by letter, don't add level to tags, sort etc ...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_tag.inc.php

    r12922 r18455  
    6565  while ($row = pwg_db_fetch_assoc($result))
    6666  {
    67     $counter = @$tag_counters[ $row['id'] ];
     67    $counter = intval(@$tag_counters[ $row['id'] ]);
    6868    if ( $counter )
    6969    {
    7070      $row['counter'] = $counter;
    7171      $row['name'] = trigger_event('render_tag_name', $row['name']);
    72       array_push($tags, $row);
     72      $tags[] = $row;
    7373    }
    7474  }
     
    9292  {
    9393    $row['name'] = trigger_event('render_tag_name', $row['name']);
    94     array_push($tags, $row);
     94    $tags[] = $row;
    9595  }
    9696
     
    139139
    140140  // display sorted tags
    141   foreach (array_keys($tags) as $k)
    142   {
    143     $tags[$k]['level'] = 1;
     141  foreach ($tags as &$tag)
     142  {
     143    $tag['level'] = 1;
    144144
    145145    // based on threshold, determine current tag level
    146146    for ($i = $conf['tags_levels'] - 1; $i >= 1; $i--)
    147147    {
    148       if ($tags[$k]['counter'] > $threshold_of_level[$i])
     148      if ($tag['counter'] > $threshold_of_level[$i])
    149149      {
    150         $tags[$k]['level'] = $i + 1;
     150        $tag['level'] = $i + 1;
    151151        break;
    152152      }
    153153    }
    154154  }
     155  unset($tag);
    155156
    156157  return $tags;
     
    255256  {
    256257    $row['name'] = trigger_event('render_tag_name', $row['name']);
    257     array_push($tags, $row);
     258    $tags[] = $row;
    258259  }
    259260  usort($tags, 'tag_alpha_compare');
Note: See TracChangeset for help on using the changeset viewer.