Optimization in QList

52 Views Asked by At

I want to optimize my code but i'm not sure, if it's worth to check, if the list is empty before calling clear?

if ( !myContainers.isEmpty() ) {
  myContainers.clear();
}

isEmpty is just a size == 0 check. What about clear? Does it iterates over all Elements and calls remove or is it so fast internally that it wouldn't make a difference?

0

There are 0 best solutions below