Skip to content

Commit

Permalink
Don't overflow when dealing with large segment numbers
Browse files Browse the repository at this point in the history
Issue: #2311

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144182445
  • Loading branch information
ojw28 committed Jan 13, 2017
1 parent ce03b8c commit 444811c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public int getSegmentNum(long timeUs, long periodDurationUs) {
} else {
// The high index cannot be unbounded. Identify the segment using binary search.
while (lowIndex <= highIndex) {
int midIndex = (lowIndex + highIndex) / 2;
int midIndex = lowIndex + (highIndex - lowIndex) / 2;
long midTimeUs = getSegmentTimeUs(midIndex);
if (midTimeUs < timeUs) {
lowIndex = midIndex + 1;
Expand Down

0 comments on commit 444811c

Please sign in to comment.