When a kernel-mode-setting driver loads it will trigger an add udev event
for /dev/dri/card0, followed by one udev change event per connector on the
card. This means that after our initial probe of the card,
create_heads_for_active_connectors is called a number of times for all the
udev change events.
After the initial enum our outputs array will contain active entries for
all connected displays. Meaning that the first loop in
create_heads_for_active_connectors would call get_output_info for
these outputs. Under the hood this does a number of ioctls and especially
the drmModeGetConnector call can be quite expensive.
Then in the second loop create_heads_for_active_connectors would call
get_output_info for all connectors, including for the once which were
checked in the first loop.
There is no reason why we cannot check if active connectors in the
old outputs array have changed when we are calling get_output_info for
all connectors to build the new array. This avoids unnecessarily making
the expensive get_output_info call twice for active connectors in the
old outputs array.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>