Results 1 to 3 of 3

Thread: Performance with static class members

Hybrid View

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

    Default Performance with static class members

    Hi,

    since I don't trust myself I just want ensure that:
    Qt Code:
    1. class A
    2. {
    3. public:
    4. static void save(QString& str)
    5. { /* huge and complex save function */ }
    6. };
    To copy to clipboard, switch view to plain text mode 
    is regarding to performance issues equal:
    Qt Code:
    1. class A {};
    2. class AHelper
    3. {
    4. static void saveHelper(const A& a, QString&str); // which "equals" a.save();
    5. };
    To copy to clipboard, switch view to plain text mode 
    assuming you have thousands of A's. (The point is, I want to hold A as small as possible.)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Performance with static class members

    That's correct, as far as I know. Static methods are really not parts of the class but rather they are exported to the global space. I think in this situation it only matters if the method is virtual or not (it's still a class method so there is no penalty for having multiple instances of the class).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Performance with static class members

    Ok, thanks, then I am going to restructure some code of mine, because I hate helper classes.

Similar Threads

  1. Abstract base class and inherited class members
    By JovianGhost in forum General Programming
    Replies: 3
    Last Post: 19th March 2010, 12:32
  2. static class members
    By space_otter in forum General Programming
    Replies: 3
    Last Post: 11th March 2010, 00:07
  3. for i = 0 to nr members in a class ...
    By qt_gotcha in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2010, 19:38
  4. Class value members & references
    By agnus in forum General Programming
    Replies: 3
    Last Post: 6th December 2009, 14:18
  5. Static functions and class members
    By Raistlin in forum General Programming
    Replies: 5
    Last Post: 22nd December 2006, 10:00

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.