diff --git a/bugsnag-plugin-android-ndk/src/main/java/com/bugsnag/android/ndk/OpaqueValue.kt b/bugsnag-plugin-android-ndk/src/main/java/com/bugsnag/android/ndk/OpaqueValue.kt index 585fa38ae2..3fccb20efc 100644 --- a/bugsnag-plugin-android-ndk/src/main/java/com/bugsnag/android/ndk/OpaqueValue.kt +++ b/bugsnag-plugin-android-ndk/src/main/java/com/bugsnag/android/ndk/OpaqueValue.kt @@ -3,6 +3,8 @@ package com.bugsnag.android.ndk import com.bugsnag.android.JsonStream import java.io.StringWriter +private const val i = 256 + /** * Marker class for values that are `BSG_METADATA_OPAQUE_VALUE` in the C layer */ @@ -10,6 +12,7 @@ internal class OpaqueValue(val json: String) { companion object { private const val MAX_NDK_STRING_LENGTH = 64 private const val US_ASCII_MAX_CODEPOINT = 127 + private const val INITIAL_BUFFER_SIZE = 256 private fun isStringNDKSupported(value: String): Boolean { // anything over 63 characters is definitely not supported @@ -27,7 +30,7 @@ internal class OpaqueValue(val json: String) { } private fun encode(value: Any): String { - val writer = StringWriter() + val writer = StringWriter(INITIAL_BUFFER_SIZE) writer.use { JsonStream(it).value(value, false) } return writer.toString() }