Menu

#4 Easy performance optimization on mouse clicks

Next_Release
closed
None
5
2014-11-16
2011-08-12
Jon Schewe
No

Instead of using a for loop in Layer::mouseEvent, use an iterator, this will really speed up the performance as you won't have to keep jumping into the list.

for(QList<Geometry*>::const_iterator iter = geometries.begin(); iter != geometries.end(); ++iter) {
Geometry *geo = *iter;
// rest of code here replacing geometries.at(i) with geo
}

You should also create the QPoint once outside the loop to avoid creating extra objects.

Another optimization would be to pass in the event to geometryClicked, then geometries could note that the click has been handled and future geometries could be skipped.

Discussion

  • Brad Grimmett

    Brad Grimmett - 2013-10-06
    • assigned_to: Brad Grimmett
    • Group: --> Next_Release
     
  • Brad Grimmett

    Brad Grimmett - 2014-11-16

    sorry this took so long to get in!
    patched in rev 56 http://sourceforge.net/p/qmapcontrol/code/56

     
  • Brad Grimmett

    Brad Grimmett - 2014-11-16
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.