Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reduced the #calls of rawurlencode() using a cache

  • Loading branch information...
commit e954224e8953bddeca26742785dfcc0ab7ce5969 1 parent 72d29c0
@ezimuel authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 library/Zend/Mvc/Router/Http/Segment.php
View
13 library/Zend/Mvc/Router/Http/Segment.php
@@ -25,6 +25,11 @@
class Segment implements RouteInterface
{
/**
+ * @var array Cache for the encode output
+ */
+ private static $__cacheEncode = array();
+
+ /**
* Map of allowed special chars in path segments.
*
* http://tools.ietf.org/html/rfc3986#appendix-A
@@ -408,9 +413,11 @@ public function getAssembledParams()
*/
private function encode($value)
{
- $encoded = rawurlencode($value);
- $encoded = strtr($encoded, static::$urlencodeCorrectionMap);
- return $encoded;
+ if (!isset(static::$__cacheEncode[$value])) {
+ static::$__cacheEncode[$value] = rawurlencode($value);
+ static::$__cacheEncode[$value] = strtr(static::$__cacheEncode[$value], static::$urlencodeCorrectionMap);
+ }
+ return static::$__cacheEncode[$value];
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.