Skip to content
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

No need to scan all string to find starting substring match #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

No need to scan all string to find starting substring match #32

wants to merge 1 commit into from

Conversation

vvendigo
Copy link

No need to scan all string to find starting substring match

@AramZS
Copy link
Contributor

AramZS commented Jul 12, 2016

Hi @vvendigo - I'm maintaining this project from upstream, can you tell me why this method would be preferred? If there is a good reason, I'll merge it in.

@vvendigo
Copy link
Author

Hi! This is just a petty optimization. Strpos() scans all the string in vain if there is no 'og:' in it. Strncmp() compares just first N chars to given string.
In the first case === 0 means that string was found at position 0, in the later 0 means that strings are equal. So condition result is the same.

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