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

Appearance settings

[Cache] Using strpbrk() instead of strcspn() is faster #21269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2017

Conversation

nicolas-grekas
Copy link
Member

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, '{}()/\@:'): 183ms

@nicolas-grekas nicolas-grekas added this to the 3.1 milestone Jan 13, 2017
@javiereguiluz
Copy link
Member

👍

Status: reviewed

@nicolas-grekas nicolas-grekas merged commit d68c451 into symfony:3.1 Jan 13, 2017
nicolas-grekas added a commit that referenced this pull request Jan 13, 2017
…colas-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, '{}()/\@:')`: 183ms

Commits
-------

d68c451 [Cache] Using strpbrk() instead of strcspn() is faster
@nicolas-grekas nicolas-grekas deleted the cache-strpbrk branch January 13, 2017 10:10
@fabpot fabpot mentioned this pull request Jan 28, 2017
@fabpot fabpot mentioned this pull request Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.