There's only a couple of variables in drupal_lookup_path() which really need to use drupal_static(). This saves about 3% of page execution time and 6,000 function calls on a node with 300 comments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Status: Active » Needs review
Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

nice. very simple patch, RTBC in my opinion.

catch’s picture

FileSize
1.38 KB

Fixed up code comments a bit after feedback from pwolanin in irc, no functional change.

Damien Tournoud’s picture

Why not having a single $cache variable:

$cache = drupal_static(__FUNCTION__, array(
  'map' => array(),
  'no_src' => array(),
  'system_paths' => array(),
  'no_alias' => array(),
  'first_call' => TRUE
);
catch’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
7.03 KB

Untested version of Damien's suggestion, which I like a lot better.

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Needs review
FileSize
7.4 KB

Fixed the test fail.

catch’s picture

FileSize
415.79 KB
386.25 KB

Halves time spent in self, takes about 1/3rd off total time too for drupal_function_exists() on the default front page.

sun’s picture

+          $cache['map'][$path_language] = db_query("SELECT src, dst FROM {url_alias} WHERE src IN(:system) AND language IN(:language, '') ORDER BY language ASC, pid ASC", array(

Missing spaces after IN.

Aside from that, this looks good to go.

This review is powered by Dreditor

catch’s picture

FileSize
7.4 KB

Fixed the whitespace.

catch’s picture

FileSize
7.69 KB

Fixed some more.

sun’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs documentation

Hm! Not only does this speed up the page execution time, the resulting code seems much easier to read, as well.

Committed to HEAD.

Seems like we also change the documentation at http://drupal.org/update/modules/6/7#static_variable_api to removes the recommendation for using the colon-suffix in favour of this array-based approach.

catch’s picture

Status: Needs work » Fixed

Updated, thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Performance, -Needs documentation

Automatically closed -- issue fixed for 2 weeks with no activity.