[Bb-trac] [bbPress] #872: maybe bb_location should cache?

bbPress bb-trac at lists.bbpress.org
Sun Apr 27 18:30:49 GMT 2008


#872: maybe bb_location should cache?
-------------------------+--------------------------------------------------
 Reporter:  _ck_         |       Owner:     
     Type:  enhancement  |      Status:  new
 Priority:  low          |   Milestone:     
Component:  Back-end     |     Version:     
 Severity:  minor        |    Keywords:     
-------------------------+--------------------------------------------------
 I've noticed that so many functions in the core and plugins rely on
 bb_location which is deceptively not as trivial as it looks.

 bb_location combs through a bunch of code to get the answer, having to do
 a great many compares if it doesn't get a hit early on. Now multiply that
 by a hundred.

 Since bb_location is always the same and can never change per instance of
 bbpress, how good/easy of an idea would it be to set `$bb->bb_location`
 the first time if it's not already set, and simply return the pre-loaded
 $bb->bb_location otherwise. The filter at the end can still run, just
 don't return it directly, store the result for return later.

 In theory this could be two or three extra lines of (backwards compatible)
 code? Something like:

 {{{
 function bb_get_location() {
 global$bb;
 if (isset($bb->bb_location)) {return $bb->bb_location;}
 }}}
 then change all the `return`s to `$bb->bb_location=`
 and make the last line `return $bb->bb_location;`

-- 
Ticket URL: <http://trac.bbpress.org/ticket/872>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list