Skip to content

Commit 78b442d

Browse files
Add fast path for empty JSValue array
1 parent adfe1e8 commit 78b442d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/JavaScriptKit/ConvertibleToJSValue.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ extension JSValue {
253253

254254
extension Array where Element == ConvertibleToJSValue {
255255
func withRawJSValues<T>(_ body: ([RawJSValue]) -> T) -> T {
256+
// fast path for empty array
257+
guard self.count != 0 else { return body([]) }
258+
256259
func _withRawJSValues<T>(
257260
_ values: [ConvertibleToJSValue], _ index: Int,
258261
_ results: inout [RawJSValue], _ body: ([RawJSValue]) -> T

0 commit comments

Comments
 (0)