Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc317e64 authored by Haoyu Zhang's avatar Haoyu Zhang
Browse files

Optimize TextView#populateCharacterBounds

Avoid unnecessary calls of getPrimaryHorizontal/getSecondaryHorizontal,
this will make the method around 2 times faster.
Also avoid repeat calls of isPositionVisible, which reduces the
computation time around 5%.

Before:
	populateCharacterBounds[mTextLength (100))]_min (ns): 416685
	populateCharacterBounds[mTextLength (300))]_min (ns): 1315209
	populateCharacterBounds[mTextLength (1,000))]_min (ns): 4480508
	populateCharacterBounds[mTextLength (3,000))]_min (ns): 13526504
	populateCharacterBounds[mTextLength (10,000))]_min (ns): 44841361

After:
        populateCharacterBounds[mTextLength (100))]_min (ns): 204065
        populateCharacterBounds[mTextLength (300))]_min (ns): 653159
        populateCharacterBounds[mTextLength (1,000))]_min (ns): 2184327
        populateCharacterBounds[mTextLength (3,000))]_min (ns): 6770318
        populateCharacterBounds[mTextLength (10,000))]_min (ns): 22777530

Bug: 233922052
Test: atest android.text.TextViewCursorAnchorInfoPerfTest
Change-Id: I24a470e204e4a2e52f881828c707adfcca21f890
parent 000f3f18
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment