[res] Optimize Theme::ApplyStyle()
This is the heaviest operation during the configuration change
handling, as we recreate the asset manager object and rebase
all existing themes on that object as soon as any assets
change. The optimization here replaces the repeated binary
search + insert in a middle of an array with a merge of two
sorted arrays in place, achieving over 7x speedup:
Before:
#BM_ThemeApplyStyleFramework 9722.817566754931 ns
After:
#BM_ThemeApplyStyleFramework 1305.8760730843824 ns
It also adds a detailed explanation of the algorithm and its
assumptions to make it easier to optimize/debug it later.
Flag: NONE A performance regression fix, flag check is too slow
Bug: 345562237
Test: build, boot, atest + performance tests
Change-Id: I979e17cf4837cc8853a8d54cb4cea2a9631c3136
4 files changed