(index) Optimize DocumentSpan.countIntersections

This commit is contained in:
Viktor Lofgren 2024-08-25 13:51:43 +02:00
parent 5660f291af
commit 893fae6d59

View File

@ -23,10 +23,15 @@ public class DocumentSpan {
} }
int cnt = 0; int cnt = 0;
int seis = 0;
for (int pi = 0; pi < positions.size(); pi++) { for (int pi = 0; pi < positions.size(); pi++) {
for (int sei = 0; sei < startsEnds.size(); sei ++) { int position = positions.getInt(pi);
if (startsEnds.getInt(sei) > positions.getInt(pi)) {
for (int sei = seis; sei < startsEnds.size(); sei ++) {
if (startsEnds.getInt(sei) > position) {
cnt += sei % 2; cnt += sei % 2;
seis = Math.max(seis, sei - 1);
break; break;
} }
} }