This repository has been archived by the owner on Jul 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlin 1.4.30 + Circumvent JS-IR performance issue with min/max + Use…
… FastArrayList on Poly2Tri
- Loading branch information
Showing
16 changed files
with
84 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
korma-shape/src/commonMain/kotlin/com/soywiz/korma/geom/shape/ops/internal/internal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.soywiz.korma.geom.shape.ops.internal | ||
|
||
@PublishedApi internal fun min2(a: Int, b: Int) = if (a < b) a else b | ||
@PublishedApi internal fun max2(a: Int, b: Int) = if (a > b) a else b | ||
|
||
@PublishedApi internal fun min2(a: Float, b: Float) = if (a < b) a else b | ||
@PublishedApi internal fun max2(a: Float, b: Float) = if (a > b) a else b | ||
|
||
@PublishedApi internal fun min2(a: Double, b: Double) = if (a < b) a else b | ||
@PublishedApi internal fun max2(a: Double, b: Double) = if (a > b) a else b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
korma/src/commonMain/kotlin/com/soywiz/korma/math/ArrayExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package com.soywiz.korma.math | ||
|
||
import com.soywiz.korma.internal.* | ||
import com.soywiz.korma.internal.max2 | ||
|
||
fun DoubleArray.minOrElse(nil: Double): Double { | ||
if (isEmpty()) return nil | ||
var out = Double.POSITIVE_INFINITY | ||
for (i in 0..lastIndex) out = kotlin.math.min(out, this[i]) | ||
for (i in 0..lastIndex) out = min2(out, this[i]) | ||
return out | ||
} | ||
|
||
fun DoubleArray.maxOrElse(nil: Double): Double { | ||
if (isEmpty()) return nil | ||
var out = Double.NEGATIVE_INFINITY | ||
for (i in 0..lastIndex) out = kotlin.math.max(out, this[i]) | ||
for (i in 0..lastIndex) out = max2(out, this[i]) | ||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters