From 0f2dc4135dee10ffe4a6908d620fd1c8c68fb606 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Sun, 22 Jun 2008 22:30:44 +0000
Subject: [PATCH] "optimiser les cas find_in_path('dirname/file') en double
 cachant"

---
 ecrire/inc/utils.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index c77d562620..4badced9cd 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -659,23 +659,23 @@ function chemin($file, $dirname='', $include=false){
 function find_in_path ($file, $dirname='', $include=false) {
 	static $files=array(), $dirs=array();
 
+	if (isset($files[$dirname][$file])) {
+		if ($include) include_once $files[$dirname][$file];
+		return  $files[$dirname][$file];
+	}
 	$a = strrpos($file,'/');
 	if ($a !== false) {
 		$dirname .= substr($file, 0, ++$a);
 		$file = substr($file, $a);
 	}
 
-	if (isset($files[$dirname][$file])) {
-		if ($include) include_once $files[$dirname][$file];
-		return  $files[$dirname][$file];
-	}
 	foreach(creer_chemin() as $dir) {
 		if (!isset($dirs[$a = $dir . $dirname]))
 			$dirs[$a] = (is_dir($a) || !$a) ;
 		if ($dirs[$a]) {
 			if (is_readable($a .= $file)) {
 				if ($include) include_once $a;
-				return $files[$dirname][$file] = $a;
+				return $files[$dirname][$file] = $files[''][$dirname . $file] = $a;
 			}
 		}
 	}
-- 
GitLab