From 640fc5b26b2dca9e40611e0d6504dd32ea33c076 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 5 Jan 2015 13:49:48 +0100 Subject: [PATCH] Optimize chars() by not repeatedly call length() --- src/Stringy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stringy.php b/src/Stringy.php index 4cb6100..c71416d 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -186,7 +186,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess public function chars() { $chars = array(); - for ($i = 0; $i < $this->length(); $i++) { + for ($i = 0, $l = $this->length(); $i < $l; $i++) { $chars[] = $this->at($i)->str; }