Skip to content

Commit

Permalink
Remove string method from lib which is direct alias from std lib method
Browse files Browse the repository at this point in the history
  • Loading branch information
jurmous committed Sep 20, 2024
1 parent bd4ea25 commit 99c1c10
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package maryk.core.processors.datastore.matchers

import maryk.core.processors.datastore.findByteIndexAndSizeByPartIndex
import maryk.core.processors.datastore.findByteIndexByPartIndex
import maryk.lib.bytes.initString
import maryk.lib.extensions.compare.matchPart

sealed class IsIndexPartialToMatch {
Expand Down Expand Up @@ -48,7 +47,7 @@ class IndexPartialToRegexMatch(
/** Matches [bytes] to partial and returns true if matches */
override fun match(bytes: ByteArray, offset: Int, length: Int): Boolean {
val (internalOffset, size) = findByteIndexAndSizeByPartIndex(indexableIndex, bytes, keySize)
return regex.matches(initString(bytes, offset + internalOffset, size))
return regex.matches(bytes.decodeToString(offset + internalOffset, size))
}
}

Expand Down
3 changes: 0 additions & 3 deletions lib/src/commonMain/kotlin/maryk/lib/bytes/String.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ private const val MIN_SUPPLEMENTARY_CODE_POINT = 0x010000
expect fun fromCodePoint(value: Int): String
expect fun codePointAt(string: String, index: Int): Int

fun initString(bytes: ByteArray, offset: Int, length: Int): String =
bytes.decodeToString(offset, offset + length)

fun initString(length: Int, reader: () -> Byte): String =
if (length > recyclableByteArray.size) {
ByteArray(length) {
Expand Down
10 changes: 0 additions & 10 deletions lib/src/commonTest/kotlin/maryk/lib/bytes/StringTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ class StringTest {
}
}

@Test
fun testBytesToString() {
for ((hex, value) in stringsAndBytes) {
val b = initByteArrayByHex(hex)
expect(value) {
initString(b, 0, b.size)
}
}
}

@Test
fun testStringToBytes() {
for ((hex, value) in stringsAndBytes) {
Expand Down

0 comments on commit 99c1c10

Please sign in to comment.