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:
@@ -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('à', 'á', 'â', 'ä', 'ã', 'ā', 'ą', 'ă', 'å', 'α',
|
||||
'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ',
|
||||
'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ',
|
||||
|
Reference in New Issue
Block a user