17

Sorry for the humorous phrasing of the question. I couldn't resist ;-)

If I emit a signal that's not connected to a slot anywhere in the code, is there still a performance cost associated with that "emission". I'm not familiar with the mechanism via which Qt's signal/slots are implemented, so I apologize if this question reveals my fundamental ignorance of Qt's underlying design.

Alan Turing
  • 12,223
  • 16
  • 74
  • 116
  • 1
    Love the question. Wish I knew the answer. – Don Roby Jun 15 '11 at 01:30
  • 6
    Standard for the Observer pattern. If makes no sound if there is nobody to observe. The effort to find a null pointer is not null. But of course nothing you ever fret about. – Hans Passant Jun 15 '11 at 01:33

1 Answers1

11

At least a small one. Qt at least needs to look into the signal's connected slot list (or something like this, not sure about that) until it sees that it doesn't have to call anything. But that performance hit should be negligable, considering that you're using such a high-level environment as Qt's signals and slots, anyway.

Christian Rau
  • 45,360
  • 10
  • 108
  • 185