Skip to content
  • Thomas Haller's avatar
    libnm: refactor implementation of "ethernet.s390-options" property · 0a8f1163
    Thomas Haller authored
    - the previous implementation of nm_setting_wired_get_s390_option()
      returned the elements in an arbitrary order (because it just iterated
      idx times over the unsorted hash table).
    
    - the API for "s390-options" suggests both accessing by index and by
      name. Storing the options in a hash-table is not optimal for lookup
      by index. It also requires us to sort the elements over and over
      again.
      Use instead a sorted array. Note that add/remove of course requires to
      move the elements (and has thus O(n)).
    
    - "s390-options" are very seldomly set. We shouldn't pay the price in every
      NMSettingWired to allocate a GHashTable and deal with it.
    
    - don't assert in nm_setting_wired_add_s390_option() and
      nm_setting_wired_remove_s390_option() that the key is valid.
      ifcfg-rh reader understandably does not want to implement additional
      logic to pre-validate the key, so any invalid keys would trigger an
      assertion failure. We have verify() for this purpose.
    0a8f1163