Refactor SpellCheckMarkerListImpl::Add()

Currently, the way this method inserts markers (except for the case where we
can insert at the end of the list) is inefficient. Its runtime is quadratic in
the number of markers being merged. We can make this more efficient by binary
searching for both the start and end of the overlapped range, and then erasing
the whole range (minus one marker, which we swap with the newly-inserted marker)
in one go. This method should now always run in time no worse than linear in the
number of markers.

BUG=707867

Review-Url: https://codereview.chromium.org/2915373002
Cr-Commit-Position: refs/heads/master@{#477051}
1 file changed