+ small optim

This commit is contained in:
kelson42 2014-08-31 19:27:23 -06:00
parent 45fccb2e38
commit c1a8b4a206
1 changed files with 5 additions and 2 deletions

View File

@ -24,13 +24,16 @@ namespace kiwix {
/* Count word */ /* Count word */
unsigned int Indexer::countWords(const string &text) { unsigned int Indexer::countWords(const string &text) {
unsigned int numWords = 1; unsigned int numWords = 1;
for(unsigned int i=0; i<text.size();) { unsigned int length = text.size();
while(i<text.size() && text[i] != ' ') {
for(unsigned int i=0; i<length;) {
while(i<length && text[i] != ' ') {
i++; i++;
} }
numWords++; numWords++;
i++; i++;
} }
return numWords; return numWords;
} }