Changeset 18455 for trunk/tags.php


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/tags.php

    r18063 r18455  
    160160  }
    161161}
    162 
    163 // +-----------------------------------------------------------------------+
    164 // |                        tag cloud construction                         |
    165 // +-----------------------------------------------------------------------+
    166 
    167 // we want only the first most represented tags, so we sort them by counter
    168 // and take the first tags
    169 usort($tags, 'counter_compare');
    170 $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
    171 
    172 // depending on its counter and the other tags counter, each tag has a level
    173 $tags = add_level_to_tags($tags);
    174 
    175 // we want tags diplayed in alphabetic order
    176 if ('letters' != $page['display_mode'])
    177 {
     162else
     163{
     164  // +-----------------------------------------------------------------------+
     165  // |                        tag cloud construction                         |
     166  // +-----------------------------------------------------------------------+
     167
     168  // we want only the first most represented tags, so we sort them by counter
     169  // and take the first tags
     170  usort($tags, 'counter_compare');
     171  $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
     172
     173  // depending on its counter and the other tags counter, each tag has a level
     174  $tags = add_level_to_tags($tags);
     175
     176  // we want tags diplayed in alphabetic order
    178177  usort($tags, 'tag_alpha_compare');
    179 }
    180 
    181 // display sorted tags
    182 foreach ($tags as $tag)
    183 {
    184   $template->append(
    185     'tags',
    186     array_merge(
    187       $tag,
    188       array(
    189         'URL' => make_index_url(
    190           array(
    191             'tags' => array($tag),
    192             )
    193           ),
     178
     179  // display sorted tags
     180  foreach ($tags as $tag)
     181  {
     182    $template->append(
     183      'tags',
     184      array_merge(
     185        $tag,
     186        array(
     187          'URL' => make_index_url(
     188            array(
     189              'tags' => array($tag),
     190              )
     191            ),
     192          )
    194193        )
    195       )
    196     );
    197 }
    198 
     194      );
     195  }
     196}
    199197// include menubar
    200198$themeconf = $template->get_template_vars('themeconf');
Note: See TracChangeset for help on using the changeset viewer.