Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcbb5332

Browse files
bug#21269 [Cache] Using strpbrk() instead of strcspn() is faster (nicolas-grekas)
This PR was merged into the 3.1 branch.Discussion----------[Cache] Using strpbrk() instead of strcspn() is faster| Q | A| ------------- | ---| Branch? | 3.1| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -Keys validation using strpbrk is faster.Eg on some micro bench:- `isset($a[strcspn($a, '{}()/\@:')])`: 278ms- `false !== strpbrk($a, '{}()/\@:')`: 183msCommits-------d68c451 [Cache] Using strpbrk() instead of strcspn() is faster
2 parentsd631609 +d68c451 commitcbb5332

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/Symfony/Component/Cache/CacheItem.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function expiresAfter($time)
101101
*
102102
* @param string $key The key to validate
103103
*
104-
* @throws InvalidArgumentException When $key is not valid.
104+
* @throws InvalidArgumentException When $key is not valid
105105
*/
106106
publicstaticfunctionvalidateKey($key)
107107
{
@@ -111,7 +111,7 @@ public static function validateKey($key)
111111
if (!isset($key[0])) {
112112
thrownewInvalidArgumentException('Cache key length must be greater than zero');
113113
}
114-
if (isset($key[strcspn($key,'{}()/\@:')])) {
114+
if (false !==strpbrk($key,'{}()/\@:')) {
115115
thrownewInvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:',$key));
116116
}
117117
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp