Commit 7103903a authored by Martin Reinecke's avatar Martin Reinecke

compactification

parent 5eb570e0
......@@ -2210,23 +2210,15 @@ template<typename T> shared_ptr<T> get_plan(size_t length)
{
lock_guard<mutex> lock(mut);
for (size_t i=0; i<nmax; ++i)
{
if (cache[i]==nullptr)
break;
if (cache[i]->length()==length)
if (cache[i] && (cache[i]->length()==length))
return cache[i];
}
}
auto plan = make_shared<T>(length);
{
lock_guard<mutex> lock(mut);
for (size_t i=0; i<nmax; ++i)
{
if (cache[i]==nullptr)
break;
if (cache[i]->length()==length)
if (cache[i] && (cache[i]->length()==length))
return cache[i];
}
cache[lastpos] = plan;
if (++lastpos>=nmax) lastpos=0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment