Fix corner case in CostManagerInit.

Change-Id: I91795d05eb78816d6d9a8cadc64d3814650d2aee
This commit is contained in:
Vincent Rabaud 2016-06-27 20:01:44 +02:00
parent ab7937a5c7
commit c7eb06f737

View File

@ -791,7 +791,8 @@ static int CostManagerInit(CostManager* const manager,
// difference is found, a new interval is created and bounded.
for (i = 0; i < cost_cache_size; ++i) {
const double cost_val = manager->cost_cache_[i];
if (fabs(cost_val - cost_prev) > min_cost_diff && cur + 1 < end) {
if (i == 0 ||
(fabs(cost_val - cost_prev) > min_cost_diff && cur + 1 < end)) {
if (i > 1) {
const int is_writable =
IsCostCacheIntervalWritable(cur->start_, cur->end_);