TeamWin / Team-Win-Recovery-Project

Core recovery files for the Team Win Recovery Project (T.W.R.P) - this is not up to date, please see https://github.com/TeamWin/android_bootable_recovery/
http://twrp.me
1.95k stars 742 forks source link

Inefficient dot-in-use check in GUIPatternPassword #647

Open midopa opened 8 years ago

midopa commented 8 years ago

Code in question: https://github.com/TeamWin/Team-Win-Recovery-Project/blob/7a48a664fd00a188044da348f34cc2e800b8a3fe/gui/patternpassword.cpp#L254

This code runs through the entire set of possible dots (mGridSize ^2) to check if the dot at index i is 'used' in the current pattern.

DotUsed is called every TOUCH_DRAG event, which seems like it can quickly add up and slow things down:

https://github.com/TeamWin/Team-Win-Recovery-Project/blob/7a48a664fd00a188044da348f34cc2e800b8a3fe/gui/patternpassword.cpp#L365

Can mDots[dot_idx].active be used instead? It gets set by ConnectDot and reset whenever the TOUCH_RELEASE event is fired. This will give you an instant lookup.

that1 commented 8 years ago

Even if this could be improved, it won't make any difference. The grid is tiny. Other things that are happening in every frame (like painting the actual dots) are several orders of magnitude more expensive.