-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix unnecessary toList/fromList calls during encode/decode process #6426
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
Changes from 10 commits
a961d01
66b7986
4880fec
0588573
01444d0
6b224fe
da44ff7
78b9548
022d463
06653f2
b4468eb
b0d6176
60d0efc
43bb4dc
1cdfc2a
42e6773
b402838
0c032c6
df349c9
34f9dca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,15 +186,15 @@ ArrayList<Object> toList() { | |
| return toListResult; | ||
| } | ||
|
|
||
| static @NonNull MessageData fromList(@NonNull ArrayList<Object> list) { | ||
| static @NonNull MessageData fromList(@NonNull ArrayList<Object> __pigeon_list) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't need to be in this PR, but we should consider just inlining all of the value expressions into the setter calls so we don't need variables, and thus don't have a collision concern. |
||
| MessageData pigeonResult = new MessageData(); | ||
| Object name = list.get(0); | ||
| Object name = __pigeon_list.get(0); | ||
| pigeonResult.setName((String) name); | ||
| Object description = list.get(1); | ||
| Object description = __pigeon_list.get(1); | ||
| pigeonResult.setDescription((String) description); | ||
| Object code = list.get(2); | ||
| Object code = __pigeon_list.get(2); | ||
| pigeonResult.setCode(Code.values()[(int) code]); | ||
| Object data = list.get(3); | ||
| Object data = __pigeon_list.get(3); | ||
| pigeonResult.setData((Map<String, String>) data); | ||
| return pigeonResult; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // found in the LICENSE file. | ||
| // Autogenerated from Pigeon, do not edit directly. | ||
| // See also: https://pub.dev/packages/pigeon | ||
| @file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass") | ||
|
||
|
|
||
| import android.util.Log | ||
| import io.flutter.plugin.common.BasicMessageChannel | ||
|
|
@@ -17,10 +18,10 @@ private fun wrapResult(result: Any?): List<Any?> { | |
| } | ||
|
|
||
| private fun wrapError(exception: Throwable): List<Any?> { | ||
| if (exception is FlutterError) { | ||
| return listOf(exception.code, exception.message, exception.details) | ||
| return if (exception is FlutterError) { | ||
| listOf(exception.code, exception.message, exception.details) | ||
| } else { | ||
| return listOf( | ||
| listOf( | ||
| exception.javaClass.simpleName, | ||
| exception.toString(), | ||
| "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) | ||
|
|
@@ -64,12 +65,11 @@ data class MessageData( | |
| val data: Map<String?, String?> | ||
| ) { | ||
| companion object { | ||
| @Suppress("UNCHECKED_CAST") | ||
| fun fromList(list: List<Any?>): MessageData { | ||
| val name = list[0] as String? | ||
| val description = list[1] as String? | ||
| val code = Code.ofRaw(list[2] as Int)!! | ||
| val data = list[3] as Map<String?, String?> | ||
| fun fromList(__pigeon_list: List<Any?>): MessageData { | ||
| val name = __pigeon_list[0] as String? | ||
| val description = __pigeon_list[1] as String? | ||
| val code = Code.ofRaw(__pigeon_list[2] as Int)!! | ||
| val data = __pigeon_list[3] as Map<String?, String?> | ||
| return MessageData(name, description, code, data) | ||
| } | ||
| } | ||
|
|
@@ -84,7 +84,6 @@ data class MessageData( | |
| } | ||
| } | ||
|
|
||
| @Suppress("UNCHECKED_CAST") | ||
| private object ExampleHostApiCodec : StandardMessageCodec() { | ||
| override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { | ||
| return when (type) { | ||
|
|
@@ -118,7 +117,6 @@ interface ExampleHostApi { | |
| /** The codec used by ExampleHostApi. */ | ||
| val codec: MessageCodec<Any?> by lazy { ExampleHostApiCodec } | ||
| /** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */ | ||
| @Suppress("UNCHECKED_CAST") | ||
| fun setUp(binaryMessenger: BinaryMessenger, api: ExampleHostApi?) { | ||
| run { | ||
| val channel = | ||
|
|
@@ -128,12 +126,12 @@ interface ExampleHostApi { | |
| codec) | ||
| if (api != null) { | ||
| channel.setMessageHandler { _, reply -> | ||
| var wrapped: List<Any?> | ||
| try { | ||
| wrapped = listOf<Any?>(api.getHostLanguage()) | ||
| } catch (exception: Throwable) { | ||
| wrapped = wrapError(exception) | ||
| } | ||
| val wrapped: List<Any?> = | ||
| try { | ||
| listOf<Any?>(api.getHostLanguage()) | ||
| } catch (exception: Throwable) { | ||
| wrapError(exception) | ||
| } | ||
| reply.reply(wrapped) | ||
| } | ||
| } else { | ||
|
|
@@ -151,12 +149,12 @@ interface ExampleHostApi { | |
| val args = message as List<Any?> | ||
| val aArg = args[0].let { if (it is Int) it.toLong() else it as Long } | ||
| val bArg = args[1].let { if (it is Int) it.toLong() else it as Long } | ||
| var wrapped: List<Any?> | ||
| try { | ||
| wrapped = listOf<Any?>(api.add(aArg, bArg)) | ||
| } catch (exception: Throwable) { | ||
| wrapped = wrapError(exception) | ||
| } | ||
| val wrapped: List<Any?> = | ||
| try { | ||
| listOf<Any?>(api.add(aArg, bArg)) | ||
| } catch (exception: Throwable) { | ||
| wrapError(exception) | ||
| } | ||
| reply.reply(wrapped) | ||
| } | ||
| } else { | ||
|
|
@@ -191,7 +189,6 @@ interface ExampleHostApi { | |
| } | ||
| } | ||
| /** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ | ||
| @Suppress("UNCHECKED_CAST") | ||
| class MessageFlutterApi(private val binaryMessenger: BinaryMessenger) { | ||
| companion object { | ||
| /** The codec used by MessageFlutterApi. */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.