Results 1 to 2 of 2

Thread: QStringList optimize code block

  1. #1
    Join Date
    Jan 2008
    Posts
    107
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    36
    Thanked 2 Times in 2 Posts

    Question QStringList optimize code block

    Hi guys,

    Given two CSV strings (ptag and pdata)...
    Want to join them in a single QStringList...

    Can the following code block be optimized?

    Qt Code:
    1. QString ptag = query.value(0).toString();
    2. QString pdata = query.value(1).toString();
    3.  
    4. QStringList tag = ptag.split(",");
    5. QStringList data = pdata.split(",");
    6.  
    7. for (int n=0; n < tag.size(); n++)
    8. this->protocols << tag.at(n) + data.at(n);
    To copy to clipboard, switch view to plain text mode 

    Thx in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QStringList optimize code block

    ++n is faster than n++, but the compiler will normally optimize that. Also
    Qt Code:
    1. int size = tag.size();
    2. for (int n = 0; n < size; ++n)
    To copy to clipboard, switch view to plain text mode 
    could help. Have you compared the speed of at() and []? Further I do not see any possibilities to speed up that code.

  3. The following user says thank you to Lykurg for this useful post:

    pdoria (27th March 2012)

Similar Threads

  1. Optimize QGraphicsItem update
    By paolom in forum Qt Programming
    Replies: 10
    Last Post: 21st March 2011, 15:29
  2. How to optimize qt libs for embedded x86?
    By yangyunzhao in forum Installation and Deployment
    Replies: 2
    Last Post: 30th June 2009, 09:47
  3. Optimize Qt Library
    By Svaths in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 15th July 2007, 22:25
  4. Replies: 7
    Last Post: 2nd June 2006, 12:48
  5. Code::Block
    By ball in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2006, 23:58

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.