perf(#523): cache asJsonObject in ChatBubble parse loops (surgical rebase onto main, preserves #514) (#523)
This commit is contained in:
1 file changed
+7
-5
@@ -1559,13 +1559,14 @@ fun parseToolOutput(
|
|||||||
} else if (appsArr != null) {
|
} else if (appsArr != null) {
|
||||||
appsArr.forEachIndexed { idx, el ->
|
appsArr.forEachIndexed { idx, el ->
|
||||||
if (el.isJsonObject) {
|
if (el.isJsonObject) {
|
||||||
|
val obj = el.asJsonObject
|
||||||
val name =
|
val name =
|
||||||
el.asJsonObject
|
obj
|
||||||
.get("name")
|
.get("name")
|
||||||
?.takeIf { !it.isJsonNull }
|
?.takeIf { !it.isJsonNull }
|
||||||
?.asString ?: "?"
|
?.asString ?: "?"
|
||||||
val pid =
|
val pid =
|
||||||
el.asJsonObject
|
obj
|
||||||
.get("pid")
|
.get("pid")
|
||||||
?.takeIf { !it.isJsonNull }
|
?.takeIf { !it.isJsonNull }
|
||||||
?.asInt
|
?.asInt
|
||||||
@@ -1586,18 +1587,19 @@ fun parseToolOutput(
|
|||||||
for (i in 0 until previewCount) {
|
for (i in 0 until previewCount) {
|
||||||
val el = elementsArr[i]
|
val el = elementsArr[i]
|
||||||
if (el.isJsonObject) {
|
if (el.isJsonObject) {
|
||||||
|
val obj = el.asJsonObject
|
||||||
val idx =
|
val idx =
|
||||||
el.asJsonObject
|
obj
|
||||||
.get("index")
|
.get("index")
|
||||||
?.takeIf { !it.isJsonNull }
|
?.takeIf { !it.isJsonNull }
|
||||||
?.asInt
|
?.asInt
|
||||||
val role =
|
val role =
|
||||||
el.asJsonObject
|
obj
|
||||||
.get("role")
|
.get("role")
|
||||||
?.takeIf { !it.isJsonNull }
|
?.takeIf { !it.isJsonNull }
|
||||||
?.asString
|
?.asString
|
||||||
val label =
|
val label =
|
||||||
el.asJsonObject
|
obj
|
||||||
.get("label")
|
.get("label")
|
||||||
?.takeIf { !it.isJsonNull }
|
?.takeIf { !it.isJsonNull }
|
||||||
?.asString
|
?.asString
|
||||||
|
|||||||
Reference in new issue
Block a user