Hi guys,

If you're working on any piece of code that needs to be relatively
high performance and you're using Qt data structure, there's a really
important caveat to be aware of:

http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Best_practices_for_application_development_Performance_management_Coding_for_performance.html#Avoiding_deep_copies_in_Qt

And I quote:

"To get the best out of implicit sharing, use the at() function rather
than the [] operator for read-only access of a (non-const) vector or
list. Since Qt's containers cannot tell whether [] appears on the left
side of an assignement or not, it assumes the worst and forces a deep
copy to occur. The at() function is not allowed on the left side of an
assignment and thus it does not create a deep copy.

A similar issue occurs when you iterate over a container with Qt's
STL-style iterators. Whenever begin() or end() is called on a
non-const container, Qt forces a deep copy to occur if the data is
shared. To prevent this, use const_iterator, constBegin(), and
constEnd() whenever possible."

This is a VERY important point if you're working in almost any thread
in Mixxx, so keep an eye out for this sort of thing (in both existing
code and whatever you're working on or reviewing). Stay vigilant!

Thanks,
Albert


--
Albert Santoni
Developer, Mixxx
http://www.mixxx.org
http://www.oscillicious.com

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Get Mixxx, the #1 Free MP3 DJ Mixing software Today
http://mixxx.org


Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to