Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1372)

Unified Diff: ios/web/navigation/crw_session_controller.mm

Issue 2540373003: [ios] Improved GetIndexForOffset performance to large offsets. (Closed)
Patch Set: Fixed test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/crw_session_controller.mm
diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm
index 23c444037556c1e2519de631f4d7fd6e2089f4bf..419550612b065324d12528403550af416a88148f 100644
--- a/ios/web/navigation/crw_session_controller.mm
+++ b/ios/web/navigation/crw_session_controller.mm
@@ -772,7 +772,7 @@ NSString* const kWindowNameKey = @"windowName";
delta++;
}
- while (delta < 0) {
+ while (delta < 0 && result > 0) {
// To stop the user getting 'stuck' on redirecting pages they weren't
// even aware existed, it is necessary to pass over pages that would
// immediately result in a redirect (the entry *before* the redirected
@@ -783,6 +783,9 @@ NSString* const kWindowNameKey = @"windowName";
--result;
++delta;
}
+ // Result may be out of bounds, so stop trying to skip redirect items and
+ // simply add the remainder.
+ result += delta;
} else if (delta > 0) {
NSInteger count = static_cast<NSInteger>([_entries count]);
if (_pendingEntry && _pendingEntryIndex == -1) {
@@ -796,7 +799,7 @@ NSString* const kWindowNameKey = @"windowName";
return NSNotFound;
}
- while (delta > 0) {
+ while (delta > 0 && result < count) {
++result;
--delta;
// As with going back, skip over redirects.
@@ -805,6 +808,9 @@ NSString* const kWindowNameKey = @"windowName";
++result;
}
}
+ // Result may be out of bounds, so stop trying to skip redirect items and
+ // simply add the remainder.
+ result += delta;
}
return result;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698