From bba1dbdb403aac067ae97c44531f6886f90fec35 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 11 Feb 2009 00:45:11 -0500 Subject: Use a router singleton --- lib/router.php | 11 ++++++++++- lib/util.php | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index 6443bf354..d47ad7118 100644 --- a/lib/router.php +++ b/lib/router.php @@ -48,6 +48,15 @@ require_once 'Net/URL/Mapper.php'; class Router { static $m = null; + static $inst = null; + + static function get() + { + if (!Router::$inst) { + Router::$inst = new Router(); + } + return Router::$inst; + } function __construct() { @@ -344,7 +353,7 @@ class Router $action_arg = array('action' => $action); if ($args) { - $args = array_merge($args, $action_arg); + $args = array_merge($action_arg, $args); } else { $args = $action_arg; } diff --git a/lib/util.php b/lib/util.php index a78af8be9..9b38b5596 100644 --- a/lib/util.php +++ b/lib/util.php @@ -669,8 +669,12 @@ function common_relative_profile($sender, $nickname, $dt=null) function common_local_url($action, $args=null, $fragment=null) { - $r = new Router(); + common_debug("Action = $action, args = " . (($args) ? '(' . implode($args, ',') . ')' : $args) . ", fragment = $fragment"); + $r = Router::get(); + $start = microtime(); $path = $r->build($action, $args, $fragment); + $end = microtime(); + common_debug("Pathbuilding took " . ($end - $start)); if ($path) { } if (common_config('site','fancy')) { -- cgit v1.2.3-54-g00ecf