Skip to content

Commit 8e53155

Browse files
authored
[Android][core] Reduce the memory footprint of calling function from the native module (#37080)
1 parent 263854d commit 8e53155

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/expo-modules-core/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
- Improved `@expo/ui/swift-ui-primitives` integrations. ([#36937](https://github.com/expo/expo/pull/36937) by [@kudo](https://github.com/kudo))
2222
- [iOS] Use dynamic type for AsyncFunction result conversion ([#36986](https://github.com/expo/expo/pull/36986) by [@jakex7](https://github.com/jakex7))
23-
- [Android] Improve time to retrieve the Expo module.
23+
- [Android] Improve time to retrieve the Expo module. ([#37082](https://github.com/expo/expo/pull/37082) by [@lukmccall](https://github.com/lukmccall))
24+
- [Android] Reduce the memory footprint of calling function from the native module. ([#37080](https://github.com/expo/expo/pull/37080) by [@lukmccall](https://github.com/lukmccall))
2425

2526
## 2.3.13 — 2025-05-08
2627

packages/expo-modules-core/android/src/main/java/expo/modules/kotlin/functions/AnyFunction.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ abstract class AnyFunction(
7373
throw InvalidArgsNumberException(args.size(), desiredArgsTypes.size, requiredArgumentsCount)
7474
}
7575

76-
val finalArgs = Array<Any?>(desiredArgsTypes.size) { null }
76+
val finalArgs = arrayOfNulls<Any?>(desiredArgsTypes.size)
7777
val argIterator = args.iterator()
7878
for (index in 0 until args.size()) {
7979
val desiredType = desiredArgsTypes[index]
@@ -100,10 +100,13 @@ abstract class AnyFunction(
100100
throw InvalidArgsNumberException(args.size, desiredArgsTypes.size, requiredArgumentsCount)
101101
}
102102

103-
val finalArgs = Array<Any?>(desiredArgsTypes.size) { null }
104-
val argIterator = args.iterator()
103+
val finalArgs = if (desiredArgsTypes.size == args.size) {
104+
args
105+
} else {
106+
arrayOfNulls<Any?>(desiredArgsTypes.size)
107+
}
105108
for (index in args.indices) {
106-
val element = argIterator.next()
109+
val element = args[index]
107110
val desiredType = desiredArgsTypes[index]
108111
exceptionDecorator({ cause ->
109112
ArgumentCastException(desiredType.kType, index, element?.javaClass.toString(), cause)

0 commit comments

Comments
 (0)