Skip to content

[5.4] Avoid unneeded function call in Str::length()#19079

Merged
taylorotwell merged 1 commit into
laravel:5.4from
vlakoff:str-length
May 6, 2017
Merged

[5.4] Avoid unneeded function call in Str::length()#19079
taylorotwell merged 1 commit into
laravel:5.4from
vlakoff:str-length

Conversation

@vlakoff
Copy link
Copy Markdown
Contributor

@vlakoff vlakoff commented May 5, 2017

Follow-up to #19047.

$nb = 10000;

$t1 = microtime(true);
for ($i = $nb; $i--; ) {
    mb_strlen('éééààà', mb_internal_encoding());
}
$t2 = microtime(true);
for ($i = $nb; $i--; ) {
    mb_strlen('éééààà');
}
$t3 = microtime(true);

echo $t2 - $t1, "\n", $t3 - $t2;

before 116ms, after 46ms

@tillkruss tillkruss changed the title Avoid unneeded function call in Str::length() [5.4] Avoid unneeded function call in Str::length() May 6, 2017
@taylorotwell taylorotwell merged commit d44c091 into laravel:5.4 May 6, 2017
@vlakoff vlakoff deleted the str-length branch May 6, 2017 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants