Minor optimization for Lazy_kernel

if a dynamic_cast succeeded, don't try again with a different type.
This commit is contained in:
Marc Glisse 2021-02-16 00:01:30 +01:00
parent 4335b167b7
commit 62e6c41096
1 changed files with 8 additions and 5 deletions

View File

@ -329,8 +329,9 @@ public:
LR * lr = dynamic_cast<LR*>(p.ptr());
// Another thread could reset lr->l between the next 2 lines, so we disable reset for Construct_weighted_point_2 in MT-mode.
// We could also always disable reset for Construct_weighted_point_2 and return lr->l here even if update_exact has run.
if(lr && (! lr->et)){
// FIXME: this is not thread-safe at all, some other thread could update_exact and clear l between the 2 lines. Same for the following functors.
return std::get<2>(lr->l);
}
return BaseClass().compute_weight_2_object()(p);
@ -409,8 +410,9 @@ public:
> LRint;
LR * lr = dynamic_cast<LR*>(p.ptr());
if(lr && (! lr->et)){
return std::get<1>(lr->l);
if(lr){
if(! lr->et)
return std::get<1>(lr->l);
} else {
LRint* lrint = dynamic_cast<LRint*>(p.ptr());
if(lrint && (! lrint->et)){
@ -464,8 +466,9 @@ public:
LR * lr = dynamic_cast<LR*>(p.ptr());
if(lr && (! lr->et)){
return std::get<1>(lr->l);
if(lr){
if(! lr->et)
return std::get<1>(lr->l);
}else{
LRint* lrint = dynamic_cast<LRint*>(p.ptr());
if(lrint && (! lrint->et)){