Skip to content
  • Mike Fleetwood's avatar
    Return and use constant reference from Device::get_path() (!94) · 21dd6fe0
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    A number of GParted methods named get_*() are returning properties and
    are return-by-value.  For objects this implies the returned value is
    copy constructed and later destroyed when it goes out of scope.  Change
    them to use return-by-constant-reference to avoid unnecessary object
    duplication.  Just have to make sure the reference goes out of scope
    before the referenced object is destroyed to avoid having a reference
    (pointer) to freed memory.  Assigning to a local variable instead of
    of a local reference still duplicates the object so can be used when the
    lifetime of the gotten object needs to be longer that the referenced
    object.
    
    Previously done for other getters here:
        d948cbcb
        Make get_custom_text() and get_generic_text() return by reference
    
    This change just makes Device::get_path() return a constant reference
    and updates uses to match to avoid copy constructing the returned value.
    
    Closes !94 - Mak...
    21dd6fe0