summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Routing
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-09-11 13:25:32 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-09-11 13:25:32 +0200
commit959bf0d1a7fd1d7a66ae015ffd86807f328f274e (patch)
treed89d3cc7d7be9102fc104f988202c7d08c9ddb23 /lib/private/AppFramework/Routing
parentef4eaaee17bd5b70ef9e37c1025af58df81921e6 (diff)
downloadnextcloud-server-959bf0d1a7fd1d7a66ae015ffd86807f328f274e.tar.gz
nextcloud-server-959bf0d1a7fd1d7a66ae015ffd86807f328f274e.zip
Cache the build ControllerName
Often a route.php file will have many N routes but only M controllers. Where N >= M. Which means that in most cases the ControllerName will be converted multiple times. This is of course far from ideal. Note that this is per app so the cache will contain at most N entries. Which is not to bad.
Diffstat (limited to 'lib/private/AppFramework/Routing')
-rw-r--r--lib/private/AppFramework/Routing/RouteConfig.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php
index e94f2e50c1d..70208725f46 100644
--- a/lib/private/AppFramework/Routing/RouteConfig.php
+++ b/lib/private/AppFramework/Routing/RouteConfig.php
@@ -36,14 +36,25 @@ use OCP\Route\IRouter;
* @package OC\AppFramework\routing
*/
class RouteConfig {
+ /** @var DIContainer */
private $container;
+
+ /** @var IRouter */
private $router;
+
+ /** @var array */
private $routes;
+
+ /** @var string */
private $appName;
+ /** @var string[] */
+ private $controllerNameCache = [];
+
/**
* @param \OC\AppFramework\DependencyInjection\DIContainer $container
* @param \OCP\Route\IRouter $router
+ * @param array $routes
* @internal param $appName
*/
public function __construct(DIContainer $container, IRouter $router, $routes) {
@@ -234,7 +245,10 @@ class RouteConfig {
*/
private function buildControllerName($controller)
{
- return $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
+ if (!isset($this->controllerNameCache[$controller])) {
+ $this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
+ }
+ return $this->controllerNameCache[$controller];
}
/**