react-native
react-native copied to clipboard
fix:reduce-computations
Summary:
The pull request optimizes the canUseCachedMeasurement function in the Yoga library by reducing redundant computations, combining conditions where possible, and enhancing readability and performance. These changes aim to improve the efficiency of the function without altering its overall implementation or behavior.
Changelog:
[GENERAL][CHANGED] - Optimized the canUseCachedMeasurement function to reduce redundant computations and improve performance.
Test Plan:
- Unit Tests: Ran existing unit tests to ensure the optimized function produces the same results as before.
- Performance Tests: Conducted performance tests to measure the execution time of the
canUseCachedMeasurementfunction before and after the optimization. - Code Review: Reviewed the changes to ensure they maintain the original logic and correctness of the function.
The tests confirmed that the optimized function is more efficient while producing the same correct outputs.
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 21,234,718 | -6 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 24,431,915 | -2 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: 8f98c58d384e71282a6147203bda84a095aba595 Branch: main
This seems sane, but I'm curious how performance was measured and what difference was seen here. My assumption would be that the compiler would reuse the same math here.
Could you please make this against the Yoga repo (https://github.com/facebook/yoga) instead of the React Native one? The two will sync when merged.
@NickGerleman https://github.com/facebook/yoga/pull/1681 we can close this one 👍