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 */
|
||||
unsigned int Indexer::countWords(const string &text) {
|
||||
unsigned int numWords = 1;
|
||||
for(unsigned int i=0; i<text.size();) {
|
||||
while(i<text.size() && text[i] != ' ') {
|
||||
unsigned int length = text.size();
|
||||
|
||||
for(unsigned int i=0; i<length;) {
|
||||
while(i<length && text[i] != ' ') {
|
||||
i++;
|
||||
}
|
||||
numWords++;
|
||||
i++;
|
||||
}
|
||||
|
||||
return numWords;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue