Avoid calling fmod twice in roundLayoutResultsToPixelGrid #1775

Closed
rshest wants to merge 1 commits from export-D67689065 into main

1 Commits

Author SHA1 Message Date
Ruslan Shestopalyuk
0804279956 Avoid calling fmod twice in roundLayoutResultsToPixelGrid (#1775)
Summary:
X-link: https://github.com/facebook/litho/pull/1036


X-link: https://github.com/facebook/react-native/pull/48404

## Changelog:
[Internal] -

This popped up when profiling some heavy UI performance, calling `fmod` operation in Yoga's `roundLayoutResultsToPixelGrid` in `PixelGrid.cpp` can be expensive, furthermore it turns out that some of the calls were redundant.

This replaces the duplicate calls to fmod with an equivalent single round operation, which for e.g. clang compiler on Windows brings the code in question from ~50 instructions (including 4 call instructions to the fmod function) down to ~30 instructions (without any external calls), and the layout operation being **~1% more efficient** for the particular benchmark I was looking into.

Differential Revision: D67689065
2024-12-28 03:54:24 -08:00