X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fspeedquantizer.cpp;h=f2b14b8a2aa8d6f6d585562739f8c111d548d787;hb=abed4a255060d5a233ec0ac2dd60af9132e29201;hp=9fa127cb3125fcce5868416d71535558d98195e8;hpb=621c5c938d70ba0d155e0eda91a708db0a52c0dc;p=r2c2.git diff --git a/source/libr2c2/speedquantizer.cpp b/source/libr2c2/speedquantizer.cpp index 9fa127c..f2b14b8 100644 --- a/source/libr2c2/speedquantizer.cpp +++ b/source/libr2c2/speedquantizer.cpp @@ -22,6 +22,8 @@ void SpeedQuantizer::learn(unsigned i, float s, float w) float SpeedQuantizer::get_speed(unsigned i) const { + if(i>=steps.size()) + throw out_of_range("SpeedQuantizer::get_speed"); if(i==0) return 0; if(steps[i].weight>=weight_limit) @@ -82,7 +84,7 @@ unsigned SpeedQuantizer::find_speed_step(float speed) const else return 0; } - return min(min(static_cast(low*speed/steps[low].speed), steps.size()-1), last+limit); + return min(min(low*speed/steps[low].speed, steps.size()-1), last+limit); } float f = (speed-steps[low].speed)/(steps[high].speed-steps[low].speed);