1
0
Fork 0

catch the range exception instead of implementing seperate bounds checks

This commit is contained in:
Kevin Matz 2022-12-06 13:36:27 -05:00
parent e7297c42ff
commit ed40a3b666
1 changed files with 5 additions and 9 deletions

View File

@ -53,16 +53,12 @@ Universe::~Universe()
*/
uint8_t Universe::slot(const uint16_t address)
{
if (address == 0)
std::lock_guard<std::mutex> lck (null_start_mutex);
try {
return null_start_data.at(address);
} catch (std::out_of_range const&) {
return 0;
if (address > null_start_data.size() - 1)
return 0;
null_start_mutex.lock();
uint8_t val = null_start_data[address];
null_start_mutex.unlock();
return val;
}
}