-
Notifications
You must be signed in to change notification settings - Fork 110
Add str_contains() function #433
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2327,6 +2327,10 @@ bool f$str_ends_with(const string &haystack, const string &needle) { | |
| return haystack.ends_with(needle); | ||
| } | ||
|
|
||
| bool f$str_contains(const string &haystack, const string &needle) { | ||
| return haystack.contains(needle); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the advantages of implementing it as a new functions instead of using already existing strpos? PHP uses similar approach: As seen in the code below, str_contains could be implemented in terms of strpos like so: return '' === $needle || false !== strpos($haystack, $needle);I would check what Maybe Also: you can run benchmarks using ktest utility. |
||
| } | ||
|
|
||
| string f$trim(const string &s, const string &what) { | ||
| const char *mask = get_mask(what); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.