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

StringUtils::Tokenize: clarify, simplify and optimize #4982

Merged
merged 1 commit into from
Jul 3, 2014

Conversation

Karlson2k
Copy link
Member

Variables names were wrong, no need to check "pos" for "string::npos", comments were incorrect (notice // Find first "non-delimiter").
@jmarshallnz ?

@@ -1164,19 +1164,16 @@ std::vector<std::string> StringUtils::Tokenize(const std::string &input, const s

void StringUtils::Tokenize(const std::string& input, std::vector<std::string>& tokens, const std::string& delimiters)
{
// Tokenize ripped from http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-7.html
tokens.clear();

This comment was marked as spam.

1. pos must be string::npos when lastPos=string::npos, so no need to check pos != string::npos in the while condition. A != a || B != b = !(A==a && B==b) = !(B==b) = B != b
2. as pos needn't be in the condition, it mayaswell be in the while loop.
3. rename variables to reflect what they do.
@Karlson2k
Copy link
Member Author

@jmarshallnz Done.
Thanks for formulating.

@Karlson2k
Copy link
Member Author

@jmarshallnz checked locally.
Fire jenkins build?

jmarshallnz added a commit that referenced this pull request Jul 3, 2014
StringUtils::Tokenize: clarify, simplify and optimize
@jmarshallnz jmarshallnz merged commit 5f4edbc into xbmc:master Jul 3, 2014
@Karlson2k Karlson2k deleted the tokenize_fix_01 branch July 4, 2014 17:00
@MartijnKaijser MartijnKaijser added this to the Helix 14.0-alpha1 milestone Jul 16, 2014
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.

None yet

3 participants