1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-12 16:24:00 +02:00

Optimize chars() by not repeatedly call length()

This commit is contained in:
vlakoff
2015-01-05 13:49:48 +01:00
parent d661047fb3
commit 640fc5b26b

View File

@@ -186,7 +186,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
public function chars() public function chars()
{ {
$chars = array(); $chars = array();
for ($i = 0; $i < $this->length(); $i++) { for ($i = 0, $l = $this->length(); $i < $l; $i++) {
$chars[] = $this->at($i)->str; $chars[] = $this->at($i)->str;
} }