Commit 9b5950d
DistanceTester: take a direct path for Overlap features
The inner distance loop dispatched every feature through a virtual
metricTestFunction::test() -> Feature::fvDistance() (which re-checks the
storable/numeric branches on every call) -> a virtual metric->distance(),
plus a permutation[] indirection -- all to compute, for a plain Overlap
feature, just (F == G ? 0 : weight).
Precompute once, in permuted order, a flat metricTestFunction array (removing
the permutation indirection) and an Overlap flag per feature, and let Overlap
features take the direct (F == G ? 0 : weight) path. Other metrics (MVDM,
numeric, ...) keep the existing path.
Measured (TRIBL2, 20k test instances, reused saved base; deterministic
instruction counts, min of 3): 161.30 B -> 155.19 B, i.e. about -8% of the
test phase. Only IB1/TRIBL2 use DistanceTester (IGTree computes no distances).
Output is byte-identical, including with +v db (which depends on the exact
distances and neighbour ordering).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent adef7ac commit 9b5950d
2 files changed
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
| |||
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
167 | | - | |
168 | | - | |
169 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
170 | 187 | | |
171 | 188 | | |
172 | 189 | | |
| |||
0 commit comments