From 43f1c49d25acfb7b6b20dcf1b9a9fbb502512204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E8=91=89=20Scarlet?= <93977077+MukjepScarlet@users.noreply.github.com> Date: Tue, 24 Jun 2025 00:21:08 +0800 Subject: [PATCH] use toArray instead of toTypedArray in ArrayDeque `toArray` is much faster than `toTypedArray` on JVM. And we don't need a typed array here. --- libraries/stdlib/src/kotlin/collections/ArrayDeque.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/stdlib/src/kotlin/collections/ArrayDeque.kt b/libraries/stdlib/src/kotlin/collections/ArrayDeque.kt index fcb30b8fbaed6..93357a0142903 100644 --- a/libraries/stdlib/src/kotlin/collections/ArrayDeque.kt +++ b/libraries/stdlib/src/kotlin/collections/ArrayDeque.kt @@ -43,7 +43,7 @@ public class ArrayDeque : AbstractMutableList { * Constructs a deque that contains the same elements as the specified [elements] collection in the same order. */ public constructor(elements: Collection) { - elementData = elements.toTypedArray() + elementData = elements.toArray() size = elementData.size if (elementData.isEmpty()) elementData = emptyElementData } @@ -657,4 +657,4 @@ public class ArrayDeque : AbstractMutableList { val head = if (isEmpty() || head < tail) head else head - elementData.size structure(head, toArray()) } -} \ No newline at end of file +}