@glandais/vcyclist-engine 5.1.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@
44
44
  var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i1;
45
45
  var listOf = kotlin_kotlin.$_$.s3;
46
46
  var numberToInt = kotlin_kotlin.$_$.h7;
47
+ var coerceIn = kotlin_kotlin.$_$.u7;
47
48
  var initMetadataForObject = kotlin_kotlin.$_$.a7;
48
49
  var toList_0 = kotlin_kotlin.$_$.h4;
49
50
  var collectionSizeOrDefault = kotlin_kotlin.$_$.x2;
@@ -51,18 +52,25 @@
51
52
  var get_lastIndex = kotlin_kotlin.$_$.o3;
52
53
  var checkBuilderCapacity = kotlin_kotlin.$_$.v2;
53
54
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.d2;
54
- var coerceIn = kotlin_kotlin.$_$.v7;
55
+ var coerceIn_0 = kotlin_kotlin.$_$.v7;
55
56
  var KFunctionImpl = kotlin_kotlin.$_$.a8;
56
57
  var initMetadataForFunctionReference = kotlin_kotlin.$_$.x6;
57
58
  var getStringHashCode = kotlin_kotlin.$_$.s6;
58
- var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
59
- var Semaphore = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f;
60
- var async = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
61
- var awaitAll = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b;
62
- var coroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d;
63
- var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
59
+ var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
60
+ var Semaphore = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
61
+ var async = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k;
62
+ var awaitAll = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c;
63
+ var coroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e;
64
+ var Exception = kotlin_kotlin.$_$.v9;
65
+ var Exception_init_$Init$ = kotlin_kotlin.$_$.x1;
66
+ var captureStack = kotlin_kotlin.$_$.e6;
64
67
  var KtMap = kotlin_kotlin.$_$.p2;
65
- var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e;
68
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.qa;
69
+ var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
70
+ var NonCancellable_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b;
71
+ var withContext = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f;
72
+ var CancellationException = kotlin_kotlin.$_$.n4;
73
+ var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
66
74
  var contentEquals = kotlin_kotlin.$_$.y2;
67
75
  var contentHashCode = kotlin_kotlin.$_$.z2;
68
76
  var objectCreate = kotlin_kotlin.$_$.i7;
@@ -70,9 +78,8 @@
70
78
  var initMetadataForCompanion = kotlin_kotlin.$_$.v6;
71
79
  var isNaN_0 = kotlin_kotlin.$_$.oa;
72
80
  var replace = kotlin_kotlin.$_$.z8;
73
- var coerceIn_0 = kotlin_kotlin.$_$.u7;
74
81
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
75
- var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
82
+ var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l;
76
83
  var joinToString = kotlin_kotlin.$_$.m3;
77
84
  var sorted = kotlin_kotlin.$_$.c4;
78
85
  var IllegalStateException_init_$Create$_0 = kotlin_kotlin.$_$.c2;
@@ -80,7 +87,7 @@
80
87
  var KProperty0 = kotlin_kotlin.$_$.c8;
81
88
  var getPropertyCallableRef = kotlin_kotlin.$_$.r6;
82
89
  var isNumber = kotlin_kotlin.$_$.d7;
83
- var await_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c;
90
+ var await_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d;
84
91
  var charSequenceLength = kotlin_kotlin.$_$.i6;
85
92
  var lazy = kotlin_kotlin.$_$.pa;
86
93
  //endregion
@@ -110,8 +117,16 @@
110
117
  initMetadataForLambda(Flux$forEachParallel$slambda, CoroutineImpl, VOID, [1]);
111
118
  initMetadataForCoroutine($forEachParallelCOROUTINE$, CoroutineImpl);
112
119
  initMetadataForObject(Flux, 'Flux', VOID, VOID, VOID, [3]);
120
+ initMetadataForClass(Hit, 'Hit');
121
+ initMetadataForClass(Await, 'Await');
122
+ initMetadataForClass(Owner, 'Owner');
123
+ initMetadataForClass(LoadAbandoned, 'LoadAbandoned', LoadAbandoned, Exception);
124
+ initMetadataForLambda(LruCache$load$slambda, CoroutineImpl, VOID, [1]);
125
+ initMetadataForLambda(LruCache$load$slambda_1, CoroutineImpl, VOID, [1]);
113
126
  initMetadataForCoroutine($getCOROUTINE$, CoroutineImpl);
114
- initMetadataForClass(LruCache, 'LruCache', VOID, VOID, VOID, [1, 0]);
127
+ initMetadataForCoroutine($lookupOrClaimCOROUTINE$, CoroutineImpl);
128
+ initMetadataForCoroutine($loadCOROUTINE$, CoroutineImpl);
129
+ initMetadataForClass(LruCache, 'LruCache', VOID, VOID, VOID, [1, 2, 0]);
115
130
  initMetadataForClass(RawTile, 'RawTile');
116
131
  initMetadataForCompanion(Companion);
117
132
  initMetadataForClass(Tile, 'Tile');
@@ -444,21 +459,21 @@
444
459
  if (path.isEmpty_y1axqb_k$())
445
460
  return emptyList();
446
461
  var out = ArrayList_init_$Create$_0(imul(path.get_size_woubt6_k$(), 2));
462
+ var anchor = path.get_c1px32_k$(0);
447
463
  // Inline function 'kotlin.collections.plusAssign' call
448
- var element = path.get_c1px32_k$(0);
464
+ var element = anchor;
449
465
  out.add_utx5q5_k$(element);
450
- var inductionVariable = 0;
451
- var last = path.get_size_woubt6_k$() - 1 | 0;
466
+ var inductionVariable = 1;
467
+ var last = path.get_size_woubt6_k$();
452
468
  if (inductionVariable < last)
453
469
  $l$loop: do {
454
470
  var i = inductionVariable;
455
471
  inductionVariable = inductionVariable + 1 | 0;
456
- var a = path.get_c1px32_k$(i);
457
- var b = path.get_c1px32_k$(i + 1 | 0);
458
- var d = Distance_instance.haversine_mrx4ab_k$(a, b);
472
+ var b = path.get_c1px32_k$(i);
473
+ var d = Distance_instance.haversine_mrx4ab_k$(anchor, b);
459
474
  if (d < minDistance)
460
475
  continue $l$loop;
461
- var between = this.generateCoordinatesBetween_nqn6s8_k$(a, b, step, d);
476
+ var between = this.generateCoordinatesBetween_nqn6s8_k$(anchor, b, step, d);
462
477
  var inductionVariable_0 = 1;
463
478
  var last_0 = between.get_size_woubt6_k$();
464
479
  if (inductionVariable_0 < last_0)
@@ -470,6 +485,7 @@
470
485
  out.add_utx5q5_k$(element_0);
471
486
  }
472
487
  while (inductionVariable_0 < last_0);
488
+ anchor = b;
473
489
  }
474
490
  while (inductionVariable < last);
475
491
  return out;
@@ -589,10 +605,11 @@
589
605
  var tmp_0 = Math.cos(lat1Rad);
590
606
  // Inline function 'kotlin.math.cos' call
591
607
  var a = tmp + tmp_0 * Math.cos(lat2Rad) * sinHalfLon * sinHalfLon;
608
+ var ac = coerceIn(a, 0.0, 1.0);
592
609
  // Inline function 'kotlin.math.sqrt' call
593
- var tmp0 = Math.sqrt(a);
610
+ var tmp0 = Math.sqrt(ac);
594
611
  // Inline function 'kotlin.math.sqrt' call
595
- var x_1 = 1.0 - a;
612
+ var x_1 = 1.0 - ac;
596
613
  // Inline function 'kotlin.math.atan2' call
597
614
  var x_2 = Math.sqrt(x_1);
598
615
  var c = 2.0 * Math.atan2(tmp0, x_2);
@@ -971,8 +988,8 @@
971
988
  tileY = tileY + 1 | 0;
972
989
  }
973
990
  var maxTile = (1 << z) - 1 | 0;
974
- tileX = coerceIn(tileX, 0, maxTile);
975
- tileY = coerceIn(tileY, 0, maxTile);
991
+ tileX = coerceIn_0(tileX, 0, maxTile);
992
+ tileY = coerceIn_0(tileY, 0, maxTile);
976
993
  return new Pixel(new TileCoordinates(tileX, tileY, z), x, y);
977
994
  };
978
995
  protoOf(ElevationFunctions).toTileCoordinatesFloat_fctdpc_k$ = function (coords, z) {
@@ -1003,10 +1020,10 @@
1003
1020
  var maxTile = (1 << z) - 1 | 0;
1004
1021
  // Inline function 'kotlin.math.floor' call
1005
1022
  var tmp$ret$9 = Math.floor(xFloat);
1006
- var x_0 = coerceIn(numberToInt(tmp$ret$9), 0, maxTile);
1023
+ var x_0 = coerceIn_0(numberToInt(tmp$ret$9), 0, maxTile);
1007
1024
  // Inline function 'kotlin.math.floor' call
1008
1025
  var tmp$ret$10 = Math.floor(yFloat);
1009
- var y = coerceIn(numberToInt(tmp$ret$10), 0, maxTile);
1026
+ var y = coerceIn_0(numberToInt(tmp$ret$10), 0, maxTile);
1010
1027
  return new TileCoordinatesFloat(x_0, y, xFloat, yFloat, z);
1011
1028
  };
1012
1029
  protoOf(ElevationFunctions).toTileCoordinates_jamtrs_k$ = function (coords, z) {
@@ -1018,11 +1035,11 @@
1018
1035
  // Inline function 'kotlin.math.floor' call
1019
1036
  var x = (tile.xFloat_1 - tile.x_1) * tileSize;
1020
1037
  var tmp$ret$0 = Math.floor(x);
1021
- var px = coerceIn(numberToInt(tmp$ret$0), 0, tileSize - 1 | 0);
1038
+ var px = coerceIn_0(numberToInt(tmp$ret$0), 0, tileSize - 1 | 0);
1022
1039
  // Inline function 'kotlin.math.floor' call
1023
1040
  var x_0 = (tile.yFloat_1 - tile.y_1) * tileSize;
1024
1041
  var tmp$ret$1 = Math.floor(x_0);
1025
- var py = coerceIn(numberToInt(tmp$ret$1), 0, tileSize - 1 | 0);
1042
+ var py = coerceIn_0(numberToInt(tmp$ret$1), 0, tileSize - 1 | 0);
1026
1043
  return new Pixel(new TileCoordinates(tile.x_1, tile.y_1, z), px, py);
1027
1044
  };
1028
1045
  protoOf(ElevationFunctions).toPixelFloat_ler4xt_k$ = function (coords, z, tileSize) {
@@ -1221,19 +1238,49 @@
1221
1238
  while (endIndex < (n - 1 | 0) && distanceM[endIndex + 1 | 0] - current <= windowSize) {
1222
1239
  endIndex = endIndex + 1 | 0;
1223
1240
  }
1241
+ var lowerWindow = current - windowSize;
1242
+ var upperWindow = current + windowSize;
1224
1243
  var totalWeight = 0.0;
1225
1244
  var weightedSum = 0.0;
1226
- var inductionVariable_0 = startIndex;
1227
- var last = endIndex;
1245
+ // Inline function 'kotlin.comparisons.maxOf' call
1246
+ var a = startIndex - 1 | 0;
1247
+ var inductionVariable_0 = Math.max(a, 0);
1248
+ var tmp0 = endIndex;
1249
+ // Inline function 'kotlin.comparisons.minOf' call
1250
+ var b = n - 2 | 0;
1251
+ var last = Math.min(tmp0, b);
1228
1252
  if (inductionVariable_0 <= last)
1229
- do {
1253
+ $l$loop_0: do {
1230
1254
  var j = inductionVariable_0;
1231
1255
  inductionVariable_0 = inductionVariable_0 + 1 | 0;
1256
+ var d0 = distanceM[j];
1257
+ var d1 = distanceM[j + 1 | 0];
1258
+ var length = d1 - d0;
1259
+ if (length <= 0.0)
1260
+ continue $l$loop_0;
1261
+ // Inline function 'kotlin.comparisons.maxOf' call
1262
+ var a_0 = Math.max(d0, lowerWindow);
1263
+ // Inline function 'kotlin.comparisons.minOf' call
1264
+ var b_0 = Math.min(d1, upperWindow);
1265
+ if (b_0 <= a_0)
1266
+ continue $l$loop_0;
1267
+ var e0 = elevationM[j];
1268
+ var slope = (elevationM[j + 1 | 0] - e0) / length;
1269
+ var m = 0.5 * (a_0 + b_0);
1270
+ // Inline function 'kotlin.math.absoluteValue' call
1271
+ var this_0 = a_0 - current;
1272
+ var ka = 1.0 - Math.abs(this_0) / windowSize;
1273
+ // Inline function 'kotlin.math.absoluteValue' call
1274
+ var this_1 = m - current;
1275
+ var km = 1.0 - Math.abs(this_1) / windowSize;
1232
1276
  // Inline function 'kotlin.math.absoluteValue' call
1233
- var this_0 = distanceM[j] - current;
1234
- var weight = 1.0 - Math.abs(this_0) / windowSize;
1235
- totalWeight = totalWeight + weight;
1236
- weightedSum = weightedSum + elevationM[j] * weight;
1277
+ var this_2 = b_0 - current;
1278
+ var kb = 1.0 - Math.abs(this_2) / windowSize;
1279
+ var fa = e0 + slope * (a_0 - d0);
1280
+ var fm = e0 + slope * (m - d0);
1281
+ var fb = e0 + slope * (b_0 - d0);
1282
+ totalWeight = totalWeight + 0.5 * (b_0 - a_0) * (ka + kb);
1283
+ weightedSum = weightedSum + (b_0 - a_0) / 6.0 * (fa * ka + 4.0 * fm * km + fb * kb);
1237
1284
  }
1238
1285
  while (!(j === last));
1239
1286
  out[i] = totalWeight > 0.0 ? weightedSum / totalWeight : elevationM[i];
@@ -1450,6 +1497,199 @@
1450
1497
  function Flux_getInstance() {
1451
1498
  return Flux_instance;
1452
1499
  }
1500
+ function Hit(value) {
1501
+ this.value_1 = value;
1502
+ }
1503
+ function Await(deferred) {
1504
+ this.deferred_1 = deferred;
1505
+ }
1506
+ function Owner(deferred) {
1507
+ this.deferred_1 = deferred;
1508
+ }
1509
+ function LoadAbandoned() {
1510
+ Exception_init_$Init$('load abandoned by its cancelled owner', this);
1511
+ captureStack(this, LoadAbandoned);
1512
+ }
1513
+ function lookupOrClaim($this, key, $completion) {
1514
+ var tmp = new $lookupOrClaimCOROUTINE$($this, key, $completion);
1515
+ tmp.result_1 = Unit_instance;
1516
+ tmp.exception_1 = null;
1517
+ return tmp.doResume_5yljmg_k$();
1518
+ }
1519
+ function load($this, key, ours, $completion) {
1520
+ var tmp = new $loadCOROUTINE$($this, key, ours, $completion);
1521
+ tmp.result_1 = Unit_instance;
1522
+ tmp.exception_1 = null;
1523
+ return tmp.doResume_5yljmg_k$();
1524
+ }
1525
+ function LruCache$load$slambda(this$0, $key, resultContinuation) {
1526
+ this.this$0__1 = this$0;
1527
+ this.$key_1 = $key;
1528
+ CoroutineImpl.call(this, resultContinuation);
1529
+ }
1530
+ protoOf(LruCache$load$slambda).invoke_9w0nwl_k$ = function ($this$withContext, $completion) {
1531
+ var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
1532
+ tmp.result_1 = Unit_instance;
1533
+ tmp.exception_1 = null;
1534
+ return tmp.doResume_5yljmg_k$();
1535
+ };
1536
+ protoOf(LruCache$load$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
1537
+ return this.invoke_9w0nwl_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1538
+ };
1539
+ protoOf(LruCache$load$slambda).doResume_5yljmg_k$ = function () {
1540
+ var suspendResult = this.result_1;
1541
+ $sm: do
1542
+ try {
1543
+ var tmp = this.state_1;
1544
+ switch (tmp) {
1545
+ case 0:
1546
+ this.exceptionState_1 = 2;
1547
+ this.this1__1 = this.this$0__1.mutex_1;
1548
+ this.owner0__1 = null;
1549
+ this.state_1 = 1;
1550
+ suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner0__1, this);
1551
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1552
+ return suspendResult;
1553
+ }
1554
+
1555
+ continue $sm;
1556
+ case 1:
1557
+ var tmp$ret$0 = Unit_instance;
1558
+ l$ret$1: do {
1559
+ var tmp_0;
1560
+ try {
1561
+ tmp$ret$0 = this.this$0__1.inFlight_1.remove_gppy8k_k$(this.$key_1);
1562
+ break l$ret$1;
1563
+ } catch ($p) {
1564
+ var tmp_1;
1565
+ var t = $p;
1566
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1567
+ throw t;
1568
+ }
1569
+ }
1570
+ while (false);
1571
+ var tmp_2 = tmp$ret$0;
1572
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1573
+ return tmp_2;
1574
+ case 2:
1575
+ throw this.exception_1;
1576
+ }
1577
+ } catch ($p_0) {
1578
+ var e = $p_0;
1579
+ if (this.exceptionState_1 === 2) {
1580
+ throw e;
1581
+ } else {
1582
+ this.state_1 = this.exceptionState_1;
1583
+ this.exception_1 = e;
1584
+ }
1585
+ }
1586
+ while (true);
1587
+ };
1588
+ protoOf(LruCache$load$slambda).create_rcuf4x_k$ = function ($this$withContext, completion) {
1589
+ var i = new LruCache$load$slambda(this.this$0__1, this.$key_1, completion);
1590
+ i.$this$withContext_1 = $this$withContext;
1591
+ return i;
1592
+ };
1593
+ function LruCache$load$slambda_0(this$0, $key, resultContinuation) {
1594
+ var i = new LruCache$load$slambda(this$0, $key, resultContinuation);
1595
+ return constructCallableReference(function ($this$withContext, $completion) {
1596
+ return i.invoke_9w0nwl_k$($this$withContext, $completion);
1597
+ }, 1);
1598
+ }
1599
+ function LruCache$load$slambda_1(this$0, $key, $value, resultContinuation) {
1600
+ this.this$0__1 = this$0;
1601
+ this.$key_1 = $key;
1602
+ this.$value_1 = $value;
1603
+ CoroutineImpl.call(this, resultContinuation);
1604
+ }
1605
+ protoOf(LruCache$load$slambda_1).invoke_88b81s_k$ = function ($this$withContext, $completion) {
1606
+ var tmp = this.create_rcuf4x_k$($this$withContext, $completion);
1607
+ tmp.result_1 = Unit_instance;
1608
+ tmp.exception_1 = null;
1609
+ return tmp.doResume_5yljmg_k$();
1610
+ };
1611
+ protoOf(LruCache$load$slambda_1).invoke_qns8j1_k$ = function (p1, $completion) {
1612
+ return this.invoke_88b81s_k$((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1613
+ };
1614
+ protoOf(LruCache$load$slambda_1).doResume_5yljmg_k$ = function () {
1615
+ var suspendResult = this.result_1;
1616
+ $sm: do
1617
+ try {
1618
+ var tmp = this.state_1;
1619
+ switch (tmp) {
1620
+ case 0:
1621
+ this.exceptionState_1 = 2;
1622
+ this.this1__1 = this.this$0__1.mutex_1;
1623
+ this.owner0__1 = null;
1624
+ this.state_1 = 1;
1625
+ suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner0__1, this);
1626
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1627
+ return suspendResult;
1628
+ }
1629
+
1630
+ continue $sm;
1631
+ case 1:
1632
+ var tmp$ret$0 = Unit_instance;
1633
+ l$ret$1: do {
1634
+ var tmp_0;
1635
+ try {
1636
+ this.this$0__1.inFlight_1.remove_gppy8k_k$(this.$key_1);
1637
+ var oldest = null;
1638
+ var tmp_1;
1639
+ if (this.this$0__1.entries_1.get_size_woubt6_k$() >= this.this$0__1.maxSize_1) {
1640
+ var tmp0 = this.this$0__1.entries_1;
1641
+ var key = this.$key_1;
1642
+ tmp_1 = !(isInterface(tmp0, KtMap) ? tmp0 : THROW_CCE()).containsKey_aw81wo_k$(key);
1643
+ } else {
1644
+ tmp_1 = false;
1645
+ }
1646
+ if (tmp_1) {
1647
+ var iter = this.this$0__1.entries_1.get_entries_p20ztl_k$().iterator_jk1svi_k$();
1648
+ oldest = iter.next_20eer_k$().get_value_j01efc_k$();
1649
+ iter.remove_ldkf9o_k$();
1650
+ }
1651
+ var tmp0_0 = this.this$0__1.entries_1;
1652
+ var tmp2 = this.$key_1;
1653
+ var value = this.$value_1;
1654
+ tmp0_0.put_4fpzoq_k$(tmp2, value);
1655
+ tmp$ret$0 = oldest;
1656
+ break l$ret$1;
1657
+ } catch ($p) {
1658
+ var tmp_2;
1659
+ var t = $p;
1660
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1661
+ throw t;
1662
+ }
1663
+ }
1664
+ while (false);
1665
+ var tmp_3 = tmp$ret$0;
1666
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1667
+ return tmp_3;
1668
+ case 2:
1669
+ throw this.exception_1;
1670
+ }
1671
+ } catch ($p_0) {
1672
+ var e = $p_0;
1673
+ if (this.exceptionState_1 === 2) {
1674
+ throw e;
1675
+ } else {
1676
+ this.state_1 = this.exceptionState_1;
1677
+ this.exception_1 = e;
1678
+ }
1679
+ }
1680
+ while (true);
1681
+ };
1682
+ protoOf(LruCache$load$slambda_1).create_rcuf4x_k$ = function ($this$withContext, completion) {
1683
+ var i = new LruCache$load$slambda_1(this.this$0__1, this.$key_1, this.$value_1, completion);
1684
+ i.$this$withContext_1 = $this$withContext;
1685
+ return i;
1686
+ };
1687
+ function LruCache$load$slambda_2(this$0, $key, $value, resultContinuation) {
1688
+ var i = new LruCache$load$slambda_1(this$0, $key, $value, resultContinuation);
1689
+ return constructCallableReference(function ($this$withContext, $completion) {
1690
+ return i.invoke_88b81s_k$($this$withContext, $completion);
1691
+ }, 1);
1692
+ }
1453
1693
  function $getCOROUTINE$(_this__u8e3s4, key, resultContinuation) {
1454
1694
  CoroutineImpl.call(this, resultContinuation);
1455
1695
  this._this__u8e3s4__1 = _this__u8e3s4;
@@ -1462,155 +1702,201 @@
1462
1702
  var tmp = this.state_1;
1463
1703
  switch (tmp) {
1464
1704
  case 0:
1465
- this.exceptionState_1 = 12;
1466
- this.this11__1 = this._this__u8e3s4__1.mutex_1;
1467
- this.owner10__1 = null;
1705
+ this.exceptionState_1 = 8;
1468
1706
  this.state_1 = 1;
1469
- suspendResult = this.this11__1.lock_ugrcvf_k$(this.owner10__1, this);
1707
+ continue $sm;
1708
+ case 1:
1709
+ if (!true) {
1710
+ this.state_1 = 9;
1711
+ continue $sm;
1712
+ }
1713
+
1714
+ this.state_1 = 2;
1715
+ suspendResult = lookupOrClaim(this._this__u8e3s4__1, this.key_1, this);
1470
1716
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
1471
1717
  return suspendResult;
1472
1718
  }
1473
1719
 
1474
1720
  continue $sm;
1475
- case 1:
1476
- var tmp$ret$2 = Unit_instance;
1477
- l$ret$3: do {
1478
- var tmp$ret$0;
1479
- l$ret$1: do {
1480
- var tmp_0;
1481
- try {
1482
- var tmp0_safe_receiver = this._this__u8e3s4__1.entries_1.remove_gppy8k_k$(this.key_1);
1483
- if (tmp0_safe_receiver == null)
1484
- null;
1485
- else {
1486
- var tmp0 = this._this__u8e3s4__1.entries_1;
1487
- var key = this.key_1;
1488
- tmp0.put_4fpzoq_k$(key, tmp0_safe_receiver);
1489
- tmp$ret$0 = tmp0_safe_receiver;
1490
- break l$ret$1;
1721
+ case 2:
1722
+ var lookup = suspendResult;
1723
+ if (lookup instanceof Hit) {
1724
+ return lookup.value_1;
1725
+ } else {
1726
+ if (lookup instanceof Owner) {
1727
+ this.state_1 = 7;
1728
+ suspendResult = load(this._this__u8e3s4__1, this.key_1, lookup.deferred_1, this);
1729
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1730
+ return suspendResult;
1731
+ }
1732
+ continue $sm;
1733
+ } else {
1734
+ if (lookup instanceof Await) {
1735
+ this.exceptionState_1 = 4;
1736
+ this.state_1 = 3;
1737
+ suspendResult = lookup.deferred_1.await_4rdzbx_k$(this);
1738
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1739
+ return suspendResult;
1491
1740
  }
1492
- tmp$ret$2 = this._this__u8e3s4__1.inFlight_1.get_wei43m_k$(this.key_1);
1493
- break l$ret$3;
1494
- } catch ($p) {
1495
- var tmp_1;
1496
- var t = $p;
1497
- this.this11__1.unlock_ulcrcl_k$(this.owner10__1);
1498
- throw t;
1741
+ continue $sm;
1742
+ } else {
1743
+ noWhenBranchMatchedException();
1499
1744
  }
1500
1745
  }
1501
- while (false);
1502
- var tmp_2 = tmp$ret$0;
1503
- this.this11__1.unlock_ulcrcl_k$(this.owner10__1);
1504
- return tmp_2;
1505
1746
  }
1506
- while (false);
1507
- var tmp_3 = tmp$ret$2;
1508
- this.this11__1.unlock_ulcrcl_k$(this.owner10__1);
1509
- var existing = tmp_3;
1510
- if (!(existing == null)) {
1511
- this.state_1 = 11;
1512
- suspendResult = existing.await_4rdzbx_k$(this);
1513
- if (suspendResult === get_COROUTINE_SUSPENDED()) {
1514
- return suspendResult;
1515
- }
1747
+
1748
+ break;
1749
+ case 3:
1750
+ return suspendResult;
1751
+ case 4:
1752
+ this.exceptionState_1 = 8;
1753
+ var tmp_0 = this.exception_1;
1754
+ if (tmp_0 instanceof LoadAbandoned) {
1755
+ var _unused_var__etf5q3 = this.exception_1;
1756
+ this.state_1 = 5;
1516
1757
  continue $sm;
1517
1758
  } else {
1518
- this.state_1 = 2;
1519
- continue $sm;
1759
+ throw this.exception_1;
1520
1760
  }
1521
1761
 
1522
- case 2:
1523
- this.ours1__1 = CompletableDeferred();
1524
- this.this9__1 = this._this__u8e3s4__1.mutex_1;
1525
- this.owner8__1 = null;
1526
- this.state_1 = 3;
1527
- suspendResult = this.this9__1.lock_ugrcvf_k$(this.owner8__1, this);
1762
+ case 5:
1763
+ this.exceptionState_1 = 8;
1764
+ this.state_1 = 6;
1765
+ continue $sm;
1766
+ case 6:
1767
+ this.state_1 = 1;
1768
+ continue $sm;
1769
+ case 7:
1770
+ return suspendResult;
1771
+ case 8:
1772
+ throw this.exception_1;
1773
+ case 9:
1774
+ return Unit_instance;
1775
+ }
1776
+ } catch ($p) {
1777
+ var e = $p;
1778
+ if (this.exceptionState_1 === 8) {
1779
+ throw e;
1780
+ } else {
1781
+ this.state_1 = this.exceptionState_1;
1782
+ this.exception_1 = e;
1783
+ }
1784
+ }
1785
+ while (true);
1786
+ };
1787
+ function $lookupOrClaimCOROUTINE$(_this__u8e3s4, key, resultContinuation) {
1788
+ CoroutineImpl.call(this, resultContinuation);
1789
+ this._this__u8e3s4__1 = _this__u8e3s4;
1790
+ this.key_1 = key;
1791
+ }
1792
+ protoOf($lookupOrClaimCOROUTINE$).doResume_5yljmg_k$ = function () {
1793
+ var suspendResult = this.result_1;
1794
+ $sm: do
1795
+ try {
1796
+ var tmp = this.state_1;
1797
+ switch (tmp) {
1798
+ case 0:
1799
+ this.exceptionState_1 = 2;
1800
+ this.this1__1 = this._this__u8e3s4__1.mutex_1;
1801
+ this.owner0__1 = null;
1802
+ this.state_1 = 1;
1803
+ suspendResult = this.this1__1.lock_ugrcvf_k$(this.owner0__1, this);
1528
1804
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
1529
1805
  return suspendResult;
1530
1806
  }
1531
1807
 
1532
1808
  continue $sm;
1533
- case 3:
1534
- var tmp$ret$6 = Unit_instance;
1535
- l$ret$7: do {
1536
- var tmp$ret$4;
1537
- l$ret$5: do {
1538
- var tmp_4;
1539
- try {
1540
- var tmp0_safe_receiver_0 = this._this__u8e3s4__1.entries_1.remove_gppy8k_k$(this.key_1);
1541
- if (tmp0_safe_receiver_0 == null)
1542
- null;
1543
- else {
1544
- var tmp0_0 = this._this__u8e3s4__1.entries_1;
1545
- var key_0 = this.key_1;
1546
- tmp0_0.put_4fpzoq_k$(key_0, tmp0_safe_receiver_0);
1547
- tmp$ret$4 = tmp0_safe_receiver_0;
1548
- break l$ret$5;
1809
+ case 1:
1810
+ var tmp$ret$2 = Unit_instance;
1811
+ l$ret$3: do {
1812
+ var tmp_0;
1813
+ try {
1814
+ var tmp$ret$0 = Unit_instance;
1815
+ l$ret$1: do {
1816
+ var hit = this._this__u8e3s4__1.entries_1.remove_gppy8k_k$(this.key_1);
1817
+ if (!(hit == null)) {
1818
+ var tmp0 = this._this__u8e3s4__1.entries_1;
1819
+ var key = this.key_1;
1820
+ tmp0.put_4fpzoq_k$(key, hit);
1821
+ tmp$ret$0 = new Hit(hit);
1822
+ break l$ret$1;
1549
1823
  }
1550
1824
  var raced = this._this__u8e3s4__1.inFlight_1.get_wei43m_k$(this.key_1);
1551
- var tmp_5;
1825
+ var tmp_1;
1552
1826
  if (!(raced == null)) {
1553
- tmp_5 = raced;
1827
+ tmp_1 = new Await(raced);
1554
1828
  } else {
1555
- var tmp0_1 = this._this__u8e3s4__1.inFlight_1;
1556
- var tmp2 = this.key_1;
1557
- var value = this.ours1__1;
1558
- tmp0_1.put_4fpzoq_k$(tmp2, value);
1559
- tmp_5 = null;
1829
+ var ours = CompletableDeferred();
1830
+ var tmp0_0 = this._this__u8e3s4__1.inFlight_1;
1831
+ var key_0 = this.key_1;
1832
+ tmp0_0.put_4fpzoq_k$(key_0, ours);
1833
+ tmp_1 = new Owner(ours);
1560
1834
  }
1561
- tmp$ret$6 = tmp_5;
1562
- break l$ret$7;
1563
- } catch ($p_0) {
1564
- var tmp_6;
1565
- var t_0 = $p_0;
1566
- this.this9__1.unlock_ulcrcl_k$(this.owner8__1);
1567
- throw t_0;
1835
+ tmp$ret$0 = tmp_1;
1568
1836
  }
1837
+ while (false);
1838
+ tmp$ret$2 = tmp$ret$0;
1839
+ break l$ret$3;
1840
+ } catch ($p) {
1841
+ var tmp_2;
1842
+ var t = $p;
1843
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1844
+ throw t;
1569
1845
  }
1570
- while (false);
1571
- var tmp_7 = tmp$ret$4;
1572
- this.this9__1.unlock_ulcrcl_k$(this.owner8__1);
1573
- return tmp_7;
1574
1846
  }
1575
1847
  while (false);
1576
- var tmp_8 = tmp$ret$6;
1577
- this.this9__1.unlock_ulcrcl_k$(this.owner8__1);
1578
- var awaitInstead = tmp_8;
1579
- if (!(awaitInstead == null)) {
1580
- this.state_1 = 10;
1581
- suspendResult = awaitInstead.await_4rdzbx_k$(this);
1582
- if (suspendResult === get_COROUTINE_SUSPENDED()) {
1583
- return suspendResult;
1584
- }
1585
- continue $sm;
1586
- } else {
1587
- this.state_1 = 4;
1588
- continue $sm;
1589
- }
1590
-
1591
- case 4:
1848
+ var tmp_3 = tmp$ret$2;
1849
+ this.this1__1.unlock_ulcrcl_k$(this.owner0__1);
1850
+ return tmp_3;
1851
+ case 2:
1852
+ throw this.exception_1;
1853
+ }
1854
+ } catch ($p_0) {
1855
+ var e = $p_0;
1856
+ if (this.exceptionState_1 === 2) {
1857
+ throw e;
1858
+ } else {
1859
+ this.state_1 = this.exceptionState_1;
1860
+ this.exception_1 = e;
1861
+ }
1862
+ }
1863
+ while (true);
1864
+ };
1865
+ function $loadCOROUTINE$(_this__u8e3s4, key, ours, resultContinuation) {
1866
+ CoroutineImpl.call(this, resultContinuation);
1867
+ this._this__u8e3s4__1 = _this__u8e3s4;
1868
+ this.key_1 = key;
1869
+ this.ours_1 = ours;
1870
+ }
1871
+ protoOf($loadCOROUTINE$).doResume_5yljmg_k$ = function () {
1872
+ var suspendResult = this.result_1;
1873
+ $sm: do
1874
+ try {
1875
+ var tmp = this.state_1;
1876
+ switch (tmp) {
1877
+ case 0:
1592
1878
  this.exceptionState_1 = 6;
1593
- this.state_1 = 5;
1879
+ this.exceptionState_1 = 2;
1880
+ this.state_1 = 1;
1594
1881
  suspendResult = this._this__u8e3s4__1.loader_1(this.key_1, this);
1595
1882
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
1596
1883
  return suspendResult;
1597
1884
  }
1598
1885
 
1599
1886
  continue $sm;
1600
- case 5:
1601
- this.TRY_RESULT4__1 = suspendResult;
1602
- this.exceptionState_1 = 12;
1603
- this.state_1 = 8;
1887
+ case 1:
1888
+ this.TRY_RESULT1__1 = suspendResult;
1889
+ this.exceptionState_1 = 6;
1890
+ this.state_1 = 4;
1604
1891
  continue $sm;
1605
- case 6:
1606
- this.exceptionState_1 = 12;
1607
- var tmp_9 = this.exception_1;
1608
- if (tmp_9 instanceof Error) {
1609
- this.t5__1 = this.exception_1;
1610
- this.this7__1 = this._this__u8e3s4__1.mutex_1;
1611
- this.owner6__1 = null;
1612
- this.state_1 = 7;
1613
- suspendResult = this.this7__1.lock_ugrcvf_k$(this.owner6__1, this);
1892
+ case 2:
1893
+ this.exceptionState_1 = 6;
1894
+ var tmp_0 = this.exception_1;
1895
+ if (tmp_0 instanceof Error) {
1896
+ this.t2__1 = this.exception_1;
1897
+ this.state_1 = 3;
1898
+ var tmp_1 = NonCancellable_getInstance();
1899
+ suspendResult = withContext(tmp_1, LruCache$load$slambda_0(this._this__u8e3s4__1, this.key_1, null), this);
1614
1900
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
1615
1901
  return suspendResult;
1616
1902
  }
@@ -1619,86 +1905,47 @@
1619
1905
  throw this.exception_1;
1620
1906
  }
1621
1907
 
1622
- case 7:
1623
- l$ret$9: do {
1624
- var tmp_10;
1625
- try {
1626
- this._this__u8e3s4__1.inFlight_1.remove_gppy8k_k$(this.key_1);
1627
- break l$ret$9;
1628
- } catch ($p_1) {
1629
- var tmp_11;
1630
- var t_1 = $p_1;
1631
- this.this7__1.unlock_ulcrcl_k$(this.owner6__1);
1632
- throw t_1;
1633
- }
1908
+ case 3:
1909
+ var tmp_2;
1910
+ var tmp_3 = this.t2__1;
1911
+ if (tmp_3 instanceof CancellationException) {
1912
+ tmp_2 = new LoadAbandoned();
1913
+ } else {
1914
+ tmp_2 = this.t2__1;
1634
1915
  }
1635
- while (false);
1636
- this.this7__1.unlock_ulcrcl_k$(this.owner6__1);
1637
- this.ours1__1.completeExceptionally_xyzekf_k$(this.t5__1);
1638
- var tmp_12 = this;
1639
- throw this.t5__1;
1640
- case 8:
1641
- this.exceptionState_1 = 12;
1642
- this.value0__1 = this.TRY_RESULT4__1;
1643
- this.this3__1 = this._this__u8e3s4__1.mutex_1;
1644
- this.owner2__1 = null;
1645
- this.state_1 = 9;
1646
- suspendResult = this.this3__1.lock_ugrcvf_k$(this.owner2__1, this);
1916
+
1917
+ this.ours_1.completeExceptionally_xyzekf_k$(tmp_2);
1918
+ var tmp_4 = this;
1919
+ throw this.t2__1;
1920
+ case 4:
1921
+ this.exceptionState_1 = 6;
1922
+ this.value0__1 = this.TRY_RESULT1__1;
1923
+ this.state_1 = 5;
1924
+ var tmp_5 = NonCancellable_getInstance();
1925
+ suspendResult = withContext(tmp_5, LruCache$load$slambda_2(this._this__u8e3s4__1, this.key_1, this.value0__1, null), this);
1647
1926
  if (suspendResult === get_COROUTINE_SUSPENDED()) {
1648
1927
  return suspendResult;
1649
1928
  }
1650
1929
 
1651
1930
  continue $sm;
1652
- case 9:
1653
- l$ret$11: do {
1654
- var tmp_13;
1655
- try {
1656
- this._this__u8e3s4__1.inFlight_1.remove_gppy8k_k$(this.key_1);
1657
- var tmp_14;
1658
- if (this._this__u8e3s4__1.entries_1.get_size_woubt6_k$() >= this._this__u8e3s4__1.maxSize_1) {
1659
- var tmp0_2 = this._this__u8e3s4__1.entries_1;
1660
- var key_1 = this.key_1;
1661
- tmp_14 = !(isInterface(tmp0_2, KtMap) ? tmp0_2 : THROW_CCE()).containsKey_aw81wo_k$(key_1);
1662
- } else {
1663
- tmp_14 = false;
1664
- }
1665
- if (tmp_14) {
1666
- var iter = this._this__u8e3s4__1.entries_1.get_entries_p20ztl_k$().iterator_jk1svi_k$();
1667
- var oldest = iter.next_20eer_k$();
1668
- var oldestValue = oldest.get_value_j01efc_k$();
1669
- iter.remove_ldkf9o_k$();
1670
- var tmp0_safe_receiver_1 = this._this__u8e3s4__1.onEvict_1;
1671
- if (tmp0_safe_receiver_1 == null)
1672
- null;
1673
- else
1674
- tmp0_safe_receiver_1(oldestValue);
1675
- }
1676
- var tmp0_3 = this._this__u8e3s4__1.entries_1;
1677
- var tmp2_0 = this.key_1;
1678
- var value_0 = this.value0__1;
1679
- tmp0_3.put_4fpzoq_k$(tmp2_0, value_0);
1680
- break l$ret$11;
1681
- } catch ($p_2) {
1682
- var tmp_15;
1683
- var t_2 = $p_2;
1684
- this.this3__1.unlock_ulcrcl_k$(this.owner2__1);
1685
- throw t_2;
1686
- }
1931
+ case 5:
1932
+ var evicted = suspendResult;
1933
+ this.ours_1.complete_ixf84q_k$(this.value0__1);
1934
+ if (!(evicted == null)) {
1935
+ var tmp0_safe_receiver = this._this__u8e3s4__1.onEvict_1;
1936
+ if (tmp0_safe_receiver == null)
1937
+ null;
1938
+ else
1939
+ tmp0_safe_receiver(evicted);
1687
1940
  }
1688
- while (false);
1689
- this.this3__1.unlock_ulcrcl_k$(this.owner2__1);
1690
- this.ours1__1.complete_ixf84q_k$(this.value0__1);
1941
+
1691
1942
  return this.value0__1;
1692
- case 10:
1693
- return suspendResult;
1694
- case 11:
1695
- return suspendResult;
1696
- case 12:
1943
+ case 6:
1697
1944
  throw this.exception_1;
1698
1945
  }
1699
- } catch ($p_3) {
1700
- var e = $p_3;
1701
- if (this.exceptionState_1 === 12) {
1946
+ } catch ($p) {
1947
+ var e = $p;
1948
+ if (this.exceptionState_1 === 6) {
1702
1949
  throw e;
1703
1950
  } else {
1704
1951
  this.state_1 = this.exceptionState_1;
@@ -2056,7 +2303,7 @@
2056
2303
  return this.distanceTo_53ug7b_k$(segmentStart);
2057
2304
  var pointVector = this.minus_de4vqf_k$(segmentStart);
2058
2305
  var projection = pointVector.dot_o3y6jk_k$(segmentVector) / segmentLengthSq;
2059
- var clamped = coerceIn_0(projection, 0.0, 1.0);
2306
+ var clamped = coerceIn(projection, 0.0, 1.0);
2060
2307
  var closest = segmentStart.plus_e4szu7_k$(segmentVector.times_qz1dds_k$(clamped));
2061
2308
  return this.distanceTo_53ug7b_k$(closest);
2062
2309
  };