1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-13 08:44:01 +02:00

Add cache in charsArray()

This is static but confined to this function block,
so this doesn't introduce any side effect.

The performance gain is really worth it.
This commit is contained in:
vlakoff
2015-01-12 19:59:37 +01:00
parent 62f6fd7b3a
commit 8676bd9d9b

View File

@@ -443,7 +443,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
*/
protected function charsArray()
{
return array(
static $charsArray;
if (isset($charsArray)) return $charsArray;
return $charsArray = array(
'a' => array('à', 'á', 'â', 'ä', 'ã', 'ā', 'ą', 'ă', 'å', 'α',
'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ',
'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ',