Skip to content

Commit 825992f

Browse files
committed
Return early when checking divider before child zero.
Previously the `getChildAt` method would be called with an index of -1 which would lead to an exception being thrown and caught. This is unnecessary since we know there will never be a divider before the first child. It also avoids additional object creation since this method can be invoked quite frequently. Change-Id: Iab44520d5d52f96a829a009cdd1201696edbf9a4
1 parent 2c93214 commit 825992f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/java/com/android/internal/view/menu/ActionMenuView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ public void initialize(MenuBuilder menu) {
524524

525525
@Override
526526
protected boolean hasDividerBeforeChildAt(int childIndex) {
527+
if (childIndex == 0) {
528+
return false;
529+
}
527530
final View childBefore = getChildAt(childIndex - 1);
528531
final View child = getChildAt(childIndex);
529532
boolean result = false;

0 commit comments

Comments
 (0)