Results 1 to 6 of 6

Thread: conditional operator good for optimization?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default conditional operator good for optimization?

    I'm trying to remove branches from my code so it consumes less %cpu.

    If I convert an inner loop if statement from:

    Qt Code:
    1. if ( b ) {
    2. a = c;
    3. } else {
    4. a = d;
    5. }
    To copy to clipboard, switch view to plain text mode 

    To:

    Qt Code:
    1. a = b ? c : d
    To copy to clipboard, switch view to plain text mode 

    Does that take a branch out of the opcode?

    Initial tests indicate this does not reduce the %cpu of my app very much.
    Last edited by mhoover; 28th December 2010 at 01:11. Reason: formatting

Similar Threads

  1. Replies: 5
    Last Post: 7th October 2010, 20:47
  2. How Does One Put a Conditional For Embedded Linux into a .pro file?
    By cloaked_and_coastin in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 27th July 2010, 15:48
  3. Replies: 2
    Last Post: 1st March 2010, 17:58
  4. Conditional linkage
    By TorAn in forum General Programming
    Replies: 1
    Last Post: 22nd December 2009, 21:10
  5. QListView with conditional vertical automatic scroll
    By jmesquita in forum Qt Programming
    Replies: 2
    Last Post: 1st August 2009, 03:09

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.