forked from Strumenta/antlr-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: do not use expensive transformation functions in critical code
Relates-to: Strumenta#49
- Loading branch information
Showing
4 changed files
with
62 additions
and
55 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
antlr-kotlin-runtime/src/commonMain/kotlin/com/strumenta/kotlinmultiplatform/Math.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,12 +1,12 @@ | ||
package com.strumenta.kotlinmultiplatform | ||
|
||
object Math { | ||
fun min(a: Int, b: Int): Int = | ||
inline fun min(a: Int, b: Int): Int = | ||
kotlin.math.min(a, b) | ||
|
||
fun max(a: Int, b: Int): Int = | ||
inline fun max(a: Int, b: Int): Int = | ||
kotlin.math.max(a, b) | ||
|
||
fun floor(d: Double): Double = | ||
inline fun floor(d: Double): Double = | ||
kotlin.math.floor(d) | ||
} |
14 changes: 14 additions & 0 deletions
14
...-kotlin-runtime/src/commonMain/kotlin/com/strumenta/kotlinmultiplatform/ext/String.ext.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,14 @@ | ||
package com.strumenta.kotlinmultiplatform.ext | ||
|
||
fun String.codePointIndices(): IntArray { | ||
val intArray = IntArray(length) | ||
var p = 0 | ||
|
||
for (i in indices) { | ||
if (!hasSurrogatePairAt(i - 1)) { | ||
intArray[p++] = i | ||
} | ||
} | ||
|
||
return intArray.copyOfRange(0, p) | ||
} |
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
1 change: 1 addition & 0 deletions
1
...r-kotlin-runtime/src/commonTest/kotlin/org/antlr/v4/kotlinruntime/StringCharStreamTest.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