Actyx / banyan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize OffsetRangeQuery

rklaehn opened this issue · comments

The Query implementation for OffsetRangeQuery is currently obviously correct, but less than optimal.

    fn containing(&self, mut offset: u64, index: &LeafIndex<T>, res: &mut [bool]) {
        let range = offset..offset + index.keys.count();
        // shortcut test
        if !&self.0.intersects(&range) {
            res.clear();
        } else {
            for i in 0..(index.keys.len()).min(res.len()) {
                if res[i] {
                    res[i] = self.0.contains(&offset);
                }
                offset += 1;
            }
        }
    }

Obviously this can be done more efficiently than checking every single offset.