[Android] Avoid unnecessray ObserverList compacting
commit4fd0d810432901cfacf58ca054a11f9fd91b6dc5
authorjdduke <jdduke@chromium.org>
Tue, 24 Feb 2015 01:34:13 +0000 (23 17:34 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 24 Feb 2015 01:35:04 +0000 (24 01:35 +0000)
treeaf2ac5f3bc9ff55cbbc654c164725514e38a76e4
parentecf4c15e342616bddbb35f80f93c864ad35cbf76
[Android] Avoid unnecessray ObserverList compacting

Currently, when an ObserverList iterator is rewound or reaches the end
of the list, it will trigger list compacting. However, the majority of
the time, no compacting is required as no elements were removed.

Change the policy to only compact if an element was removed during
list iteration, avoiding unnecessary O(N) list walks.

BUG=440134

Review URL: https://codereview.chromium.org/943303005

Cr-Commit-Position: refs/heads/master@{#317725}
base/android/java/src/org/chromium/base/ObserverList.java