Skip to content

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