The class of a GObject cannot change during its lifetime. And also the
the class itself not change (e.g. change the virtual methods).
As such, we can cache CLASS_NEEDS_NOTIFY() per object.
This way, our _g_object_has_notify_handler() only needs to compare the
flags, instead of fetching the class and check the vtable.
You might think, CLASS_NEEDS_NOTIFY() is cheaper to check, because it
doesn't need an atomic operation to fetch the class and compare the
vtable (unlike checking the object's optional-flags). You might also
think a constant flag should not be attached to the object's
optional-flags (which otherwise change). However, in all cases where we
care about CLASS_NEEDS_NOTIFY(), we anyway also check for
OPTIONAL_FLAG_HAS_NOTIFY_HANDLER which is right beside in the the
optional-flags. So having the OPTIONAL_FLAG_HAS_NEEDS_NOTIFY flag right
beside has no downside.