mirror of https://github.com/kiwix/libkiwix.git
+ small optim
This commit is contained in:
parent
45fccb2e38
commit
c1a8b4a206
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue