Skip to content

Commit 5540dd3

Browse files
committed
remove the last optimization
1 parent 13f1059 commit 5540dd3

12 files changed

+13100
-63
lines changed

CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.5.1] Unreleased
8+
## [1.5.1] 2020-09-28
99

1010
### Added
1111
- Unit testing of all distances reported
@@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Changed
1818
- Significantly faster processing of triangles
19-
- Significantly faster processing of 3 TP distances
2019

2120
## [1.5.0] 2020-07-10
2221

doc/global.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ig
267267
<br class="clear">
268268

269269
<footer>
270-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 17:45:31 GMT+0200 (Central European Summer Time)
270+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 18:19:32 GMT+0200 (Central European Summer Time)
271271
</footer>
272272

273273
<script> prettyPrint(); </script>

doc/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ig
5656
<br class="clear">
5757

5858
<footer>
59-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 17:45:31 GMT+0200 (Central European Summer Time)
59+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 18:19:32 GMT+0200 (Central European Summer Time)
6060
</footer>
6161

6262
<script> prettyPrint(); </script>

doc/module-igc-xc-score.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ig
574574
<br class="clear">
575575

576576
<footer>
577-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 17:45:31 GMT+0200 (Central European Summer Time)
577+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 18:19:32 GMT+0200 (Central European Summer Time)
578578
</footer>
579579

580580
<script> prettyPrint(); </script>

doc/scoring-rules.config.js.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ig
171171
<br class="clear">
172172

173173
<footer>
174-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 17:45:31 GMT+0200 (Central European Summer Time)
174+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 18:19:32 GMT+0200 (Central European Summer Time)
175175
</footer>
176176

177177
<script> prettyPrint(); </script>

doc/solver.js.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ig
171171
<br class="clear">
172172

173173
<footer>
174-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 17:45:31 GMT+0200 (Central European Summer Time)
174+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Mon Sep 28 2020 18:19:32 GMT+0200 (Central European Summer Time)
175175
</footer>
176176

177177
<script> prettyPrint(); </script>

geom.js

+14-26
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,19 @@ function findFurthestPointInSegment(sega, segb, target, opt) {
242242
let distanceMax = -Infinity;
243243
let fpoint;
244244
for (let v of points) {
245-
const precomputedAll = opt.flight.furthestPoints[pos].search({ minX: v.x, minY: v.y, maxX: v.x, maxY: v.y, ...zSearch });
246245
let distanceVMax = -Infinity;
247246
let fVpoint;
248-
for (let precomp of precomputedAll) {
249-
if (sega <= precomp.o.r && precomp.o.r <= segb) {
250-
const d = v.distanceEarth(precomp.o);
251-
if (d > distanceVMax) {
252-
fVpoint = precomp.o;
253-
distanceVMax = d;
254-
}
255-
}
256-
}
247+
248+
const precomputed = opt.flight.furthestPoints[pos].search({ minX: v.x, minY: v.y, maxX: v.x, maxY: v.y, ...zSearch });
249+
if (precomputed.length > 1)
250+
throw new Error('furthestPoints cache inconsistency');
251+
252+
if (precomputed[0])
253+
if (sega <= precomputed[0].o.r && precomputed[0].o.r <= segb) {
254+
distanceVMax = v.distanceEarth(precomputed[0].o);
255+
fVpoint = precomputed[0].o;
256+
} else
257+
throw new Error('furthestPoints cache inconsistency');
257258

258259
if (fVpoint === undefined) {
259260
let intersecting = false;
@@ -283,27 +284,14 @@ function findFurthestPointInSegment(sega, segb, target, opt) {
283284
}
284285
}
285286
if (canCache) {
286-
let xCache, yCache, zCache;
287+
let zCache;
287288
if (sega === opt.launch) {
288289
zCache = { minZ: +fVpoint.r, maxZ: +segb };
289290
} else if (segb === opt.landing) {
290291
zCache = { minZ: +sega, maxZ: +fVpoint.r };
291292
}
292-
if (fVpoint.x > v.x) {
293-
xCache = { minX: -1000, maxX: v.x };
294-
} else {
295-
xCache = { minX: v.x, maxX: 1000 };
296-
}
297-
if (fVpoint.y > v.y) {
298-
yCache = { minY: -1000, maxY: v.y };
299-
} else {
300-
yCache = { minY: v.y, maxY: 1000 };
301-
}
302-
const old = opt.flight.furthestPoints[pos].search({ ...xCache, ...yCache, ...zCache });
303-
for (let o of old)
304-
if (o.o.r == fVpoint.r)
305-
opt.flight.furthestPoints[pos].remove(o);
306-
opt.flight.furthestPoints[pos].insert({ ...xCache, ...yCache, ...zCache, o: fVpoint });
293+
294+
opt.flight.furthestPoints[pos].insert({ minX: v.x, maxX: v.x, minY: v.y, maxY: v.y, ...zCache, o: fVpoint });
307295
}
308296
}
309297
if (distanceVMax > distanceMax) {

igc-xc-score.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.cjs.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.es.js

+14-26
Original file line numberDiff line numberDiff line change
@@ -2256,18 +2256,19 @@ function findFurthestPointInSegment(sega, segb, target, opt) {
22562256
let distanceMax = -Infinity;
22572257
let fpoint;
22582258
for (let v of points) {
2259-
const precomputedAll = opt.flight.furthestPoints[pos].search({ minX: v.x, minY: v.y, maxX: v.x, maxY: v.y, ...zSearch });
22602259
let distanceVMax = -Infinity;
22612260
let fVpoint;
2262-
for (let precomp of precomputedAll) {
2263-
if (sega <= precomp.o.r && precomp.o.r <= segb) {
2264-
const d = v.distanceEarth(precomp.o);
2265-
if (d > distanceVMax) {
2266-
fVpoint = precomp.o;
2267-
distanceVMax = d;
2268-
}
2269-
}
2270-
}
2261+
2262+
const precomputed = opt.flight.furthestPoints[pos].search({ minX: v.x, minY: v.y, maxX: v.x, maxY: v.y, ...zSearch });
2263+
if (precomputed.length > 1)
2264+
throw new Error('furthestPoints cache inconsistency');
2265+
2266+
if (precomputed[0])
2267+
if (sega <= precomputed[0].o.r && precomputed[0].o.r <= segb) {
2268+
distanceVMax = v.distanceEarth(precomputed[0].o);
2269+
fVpoint = precomputed[0].o;
2270+
} else
2271+
throw new Error('furthestPoints cache inconsistency');
22712272

22722273
if (fVpoint === undefined) {
22732274
let intersecting = false;
@@ -2297,27 +2298,14 @@ function findFurthestPointInSegment(sega, segb, target, opt) {
22972298
}
22982299
}
22992300
if (canCache) {
2300-
let xCache, yCache, zCache;
2301+
let zCache;
23012302
if (sega === opt.launch) {
23022303
zCache = { minZ: +fVpoint.r, maxZ: +segb };
23032304
} else if (segb === opt.landing) {
23042305
zCache = { minZ: +sega, maxZ: +fVpoint.r };
23052306
}
2306-
if (fVpoint.x > v.x) {
2307-
xCache = { minX: -1000, maxX: v.x };
2308-
} else {
2309-
xCache = { minX: v.x, maxX: 1000 };
2310-
}
2311-
if (fVpoint.y > v.y) {
2312-
yCache = { minY: -1000, maxY: v.y };
2313-
} else {
2314-
yCache = { minY: v.y, maxY: 1000 };
2315-
}
2316-
const old = opt.flight.furthestPoints[pos].search({ ...xCache, ...yCache, ...zCache });
2317-
for (let o of old)
2318-
if (o.o.r == fVpoint.r)
2319-
opt.flight.furthestPoints[pos].remove(o);
2320-
opt.flight.furthestPoints[pos].insert({ ...xCache, ...yCache, ...zCache, o: fVpoint });
2307+
2308+
opt.flight.furthestPoints[pos].insert({ minX: v.x, maxX: v.x, minY: v.y, maxY: v.y, ...zCache, o: fVpoint });
23212309
}
23222310
}
23232311
if (distanceVMax > distanceMax) {

test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const tests = {
1818
{ file: 'd3p.igc', score: 60.77 },
1919
{ file: 'fai.igc', score: 228.71 },
2020
{ file: 'fai.igc', score: 228.72, config: { hp: true } },
21-
{ file: 'line.igc', score: 53.34, md5: '93261059dcfcf8f68a2971ad68596bfa' },
21+
{ file: 'line.igc', score: 53.34, md5: '23584c29d94bc9ec136cb1861276258f' },
2222
{ file: 'tri.igc', score: 17.51, md5: 'c4ae239fff97533b9f42bd32469e8435' },
2323
{ file: 'record_de_france.igc', score: 422.02 },
2424
{ file: 'record_de_france.igc', score: 421.99, config: { hp: true } },
@@ -30,7 +30,8 @@ const tests = {
3030
{ file: 'hiking-up.igc', score: 40.53 },
3131
{ file: 'hiking-up-2.igc', score: 125.94 },
3232
{ file: 'lunch-break.igc', score: 73.92 },
33-
{ file: 'dup-fixes.igc', score: 89.1 }
33+
{ file: 'dup-fixes.igc', score: 89.1 },
34+
{ file: 'd3p-anti-cache.igc', score: 58.53 }
3435
],
3536
XContest: [
3637
{ file: 'flat-xcontest-106.82.igc', score: 107.12 },

0 commit comments

Comments
 (0)