diff --git a/lib/app.php b/lib/app.php
index 61566ed7522c46d4b3325e50d164873b15adc590..d1f12594a2511a00b3868c722d91575b8f5cbb90 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -350,9 +350,13 @@ class OC_App{
 
 
 	protected static function findAppInDirectories($appid) {
+		static $app_dir = array();
+		if (isset($app_dir[$appid])) {
+			return $app_dir[$appid];
+		}
 		foreach(OC::$APPSROOTS as $dir) {
 			if(file_exists($dir['path'].'/'.$appid)) {
-				return $dir;
+				return $app_dir[$appid]=$dir;
 			}
 		}
 	}