Commit ba1ede6
perf: Faster WritableNativeMap.putString value conversion (#58644)
Summary:
I found (while working on #58611) that `WritableNativeMap::putString` converted its value with fbjni toString(), which calls Java Object.toString() through JNI before running toStdString(). Since the value is already a `jstring`, I call `toStdString()` directly, which produces identical bytes with one fewer JNI call and local reference.
| Value | Before | After | Delta |
|---|---|---|---|
| 11 ASCII | 0.205 | 0.191 | -6.8% |
| 100 ASCII | 0.265 | 0.231 | -12.8% |
| 300 ASCII | 0.451 | 0.418 | -7.3% |
| 1000 ASCII | 0.984 | 0.966 | -1.8% |
| 100 CJK | 0.325 | 0.298 | -8.3% |
## Changelog:
[ANDROID] [CHANGED] - Skip a redundant JNI Object.toString() call in WritableNativeMap.putString.
Pull Request resolved: #58644
Test Plan: I measured putString at 0.614 → 0.474 µs per call for short strings (-23%) on a Galaxy M14, identical output on 21 edge-case strings.
Reviewed By: cortinico
Differential Revision: D121774499
Pulled By: javache
fbshipit-source-id: a20a3d64c6afaf75515f3c3e8173c8e86a1122ce1 parent ec2b536 commit ba1ede6
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
0 commit comments