New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix InvalidMutabilityException in RegexToken #41
Fix InvalidMutabilityException in RegexToken #41
Conversation
@@ -40,8 +37,7 @@ public actual class RegexToken : Token { | |||
} | |||
|
|||
override fun match(input: CharSequence, fromIndex: Int): Int { | |||
relativeInput.input = input | |||
relativeInput.fromIndex = fromIndex | |||
val relativeInput = RelativeInput(fromIndex, input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, an instance of RelativeInput
is created on each invocation of match
, which, if not properly optimized, might cause a performance drop. I'd like to check how the benchmarks run on a native platform before and after the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, benchmarks
subproject does not seem to support native targets. Do you want me to add one?
Also, how does the |
@h0tk3y sorry, the last month was very busy for me. I have added a test showing how to reproduce the error in concurrent scenario. |
@h0tk3y ping |
It seems like the fix doesn't affect the Kotlin/Native benchmarks in any noticeable way. I'm accepting it now and will publish a new release sometime soon. Thanks a lot! |
@h0tk3y thanks for merging the PR. How soon can we expect the new version to be released? |
Mutating
relativeInput
makes better-parse throwInvalidMutabilityException
on iosX64 (probably on other Kotlin/Native platforms as well). This PR turnsrelativeInput
into a local immutable object.