+ // Try to find the begin of searched string
+ int increment = mres.pos/2;
+ while (mres.pos > 5 && (increment > 5)) {
+ DocIterator old_cur = cur;
+ for (int i = 0; i < increment && cur; cur.forwardPos(), i++) {
+ /*
+ while (cur && cur.depth() != old_cur.depth())
+ cur.forwardPos();
+ */
+ }
+ if (! cur) {
+ cur = old_cur;
+ increment /= 2;
+ }
+ else {
+ MatchResult mres2 = match(cur, -1, false);
+ if ((mres2.match2end < mres.match2end) ||
+ (mres2.match_len < mres.match_len)) {
+ cur = old_cur;
+ increment /= 2;
+ }
+ else {
+ mres = mres2;
+ increment -= 2;
+ if (increment > mres.pos/2)
+ increment = mres.pos/2;
+ }
+ }
+ }