Skip to content
  • Thomas Haller's avatar
    core: remove NMDedupMultiBox object and track NMDedupMultiObj instances directly · 28340588
    Thomas Haller authored
    Implement the reference counting of NMPObject as part of
    NMDedupMultiObj and get rid of NMDedupMultiBox.
    
    With this change, the NMPObject is aware in which NMDedupMultiIndex
    instance it is tracked.
    
    - this saves an additional GSlice allocation for the NMDedupMultiBox.
    
    - it is immediately known, whether an NMPObject is tracked by a
      certain NMDedupMultiIndex or not. This saves an additional hash
      lookup.
    
    - previously, when all idx-types cease to reference an NMDedupMultiObj
      instance, it was removed. Now, a tracked objects stays in the
      NMDedupMultiIndex until it's last reference is deleted. This possibly
      extends the lifetime of the object and we may reuse it better.
    
    - it is no longer possible to add one object to more then one
      NMDedupMultiIndex instance. As we anyway want to have only one
      instance to deduplicate the objects, this is fine.
    
    - the ref-counting implementation is now part of NMDedupMultiObj.
      Previously, NMDedupMultiIndex could also track objects that were
      not ref-counted. Hoever, the object anyway *must* implement the
      NMDedupMultiObj API, so this flexibility is unneeded and was not
      used.
    
    - a downside is, that NMPObject grows by one pointer size, even if
      it isn't tracked in the NMDedupMultiIndex. But we really want to
      put all objects into the index for sharing and deduplication. So
      this downside should be acceptable. Still, code like
      nmp_object_stackinit*() needs to handle a larger object.
    28340588