Results 1 to 20 of 25

Thread: Reverse Order on QStringList slow...?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reverse Order on QStringList slow...?

    Just to post my latest findings (of how you can speed up standard algorithms when you work with Qt types)

    I simply added the following code:
    Qt Code:
    1. static inline void swap(QString& a, QString& b)
    2. {
    3. qSwap(a,b);
    4. }
    To copy to clipboard, switch view to plain text mode 

    That changed the result to:
    2000000 iterations of oldReverseList in 13 seconds
    2000000 iterations of newReverseList in 7 seconds
    2000000 iterations of stdReverseList in 7 seconds
    2000000 iterations of std2ReverseList in 6 seconds
    That means you get very easily a great(*) speedup because the STL can now use the optimizations used in qSwap. (Still not as fast as the overall winner here, but the absolute winner in the work/result ratio category :-)

    (*): "great" of course only if you do 2000000 million iterations of a reverse list algorithm...which you probably do not do ;-)
    but its probably a thing to keep in mind if you find the std algorithms taking too long for your taste :-)
    Last edited by camel; 20th February 2007 at 15:01.

Similar Threads

  1. QStringList in QObject::connect
    By DPinLV in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2006, 17:01
  2. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 20:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.