Remove sequence with list builder in Name::parse to fix problem in Wasm

This commit is contained in:
Alexander Nozik 2024-06-04 17:55:25 +03:00
parent 5a75b05acd
commit 04238295e2

View File

@ -58,7 +58,7 @@ public class Name(public val tokens: List<NameToken>) {
*/ */
public fun parse(string: String): Name { public fun parse(string: String): Name {
if (string.isBlank()) return EMPTY if (string.isBlank()) return EMPTY
val tokens = sequence { val tokens = buildList<NameToken> {
var bodyBuilder = StringBuilder() var bodyBuilder = StringBuilder()
var queryBuilder = StringBuilder() var queryBuilder = StringBuilder()
var bracketCount = 0 var bracketCount = 0
@ -91,7 +91,7 @@ public class Name(public val tokens: List<NameToken>) {
else -> when (it) { else -> when (it) {
'.' -> { '.' -> {
val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString() val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString()
yield(NameToken(bodyBuilder.toString(), query)) add(NameToken(bodyBuilder.toString(), query))
bodyBuilder = StringBuilder() bodyBuilder = StringBuilder()
queryBuilder = StringBuilder() queryBuilder = StringBuilder()
} }
@ -106,9 +106,9 @@ public class Name(public val tokens: List<NameToken>) {
} }
} }
val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString() val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString()
yield(NameToken(bodyBuilder.toString(), query)) add(NameToken(bodyBuilder.toString(), query))
} }
return Name(tokens.toList()) return Name(tokens)
} }
} }
} }