Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Leverage array_is_list(), get_debug_type(), is_countable(), is_iterable(), str_contains() and str_starts_with() #45978

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
Apr 9, 2022

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Apr 8, 2022

Q A
Branch? 6.1
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Found some things from the "past" again 😄

@carsonbot carsonbot added this to the 6.1 milestone Apr 8, 2022
@@ -56,7 +56,7 @@ protected function matches($crawler): bool
$this->hasNode = true;
$this->nodeText = $crawler->text(null, true);

return false !== mb_strpos($this->nodeText, $this->expectedText);
return str_contains($this->nodeText, $this->expectedText);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the str_contains RFC:

In a recent discussion in the internals mailing list, we came to the conclusion, there is no need for a multibyte variant of this function (e.g. mb_str_contains). The reason behind this is: A multibyte variant of this function would behave no different than the non-multibyte function. Multibyte variants behave differently when the offset/position has relevance at which the string was found. As this is not the case for this function, there is no need for that.

And from what I understood, it's the same for str_starts_with() and str_ends_with().

@fabpot
Copy link
Member

fabpot commented Apr 9, 2022

Thank you @fancyweb.

@fabpot fabpot merged commit 1f514f9 into symfony:6.1 Apr 9, 2022
nicolas-grekas added a commit that referenced this pull request Apr 12, 2022
… code paths (nicolas-grekas)

This PR was merged into the 6.1 branch.

Discussion
----------

[Cache][String] Don't use is_iterable() in perf-critical code paths

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This is 5 times faster than calling `is_iterable()`

Partially reverting #45978 /cc `@fancyweb` FYI.

Commits
-------

33fa00c [Cache][String] Don't use is_iterable() in perf-critical code paths
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.

6 participants