Cache multiple flexihashes
otherwise get_thumb / get_image / get_thumb / get_image / ... will have 100% cache miss rate
This commit is contained in:
		
							parent
							
								
									8ec3690f8e
								
							
						
					
					
						commit
						3c6b09110a
					
				| @ -812,16 +812,17 @@ class Image | |||||||
|             $tmpl = $plte->link; |             $tmpl = $plte->link; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         static $flexihash = null; |         static $flexihashes = []; | ||||||
|         static $fh_last_opts = null; |  | ||||||
|         $matches = []; |         $matches = []; | ||||||
|         if (preg_match("/(.*){(.*)}(.*)/", $tmpl, $matches)) { |         if (preg_match("/(.*){(.*)}(.*)/", $tmpl, $matches)) { | ||||||
|             $pre = $matches[1]; |             $pre = $matches[1]; | ||||||
|             $opts = $matches[2]; |             $opts = $matches[2]; | ||||||
|             $post = $matches[3]; |             $post = $matches[3]; | ||||||
| 
 | 
 | ||||||
|             if ($opts != $fh_last_opts) { |             if(isset($flexihashes[$opts])) { | ||||||
|                 $fh_last_opts = $opts; |                 $flexihash = $flexihashes[$opts]; | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|                 $flexihash = new Flexihash\Flexihash(); |                 $flexihash = new Flexihash\Flexihash(); | ||||||
|                 foreach (explode(",", $opts) as $opt) { |                 foreach (explode(",", $opts) as $opt) { | ||||||
|                     $parts = explode("=", $opt); |                     $parts = explode("=", $opt); | ||||||
| @ -837,6 +838,7 @@ class Image | |||||||
|                     } |                     } | ||||||
|                     $flexihash->addTarget($opt_val, $opt_weight); |                     $flexihash->addTarget($opt_val, $opt_weight); | ||||||
|                 } |                 } | ||||||
|  |                 $flexihashes[$opts] = $flexihash; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // $choice = $flexihash->lookup($pre.$post);
 |             // $choice = $flexihash->lookup($pre.$post);
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user