Skip to content
  • Romain Vimont's avatar
    Return blocks by reference, not by value · 86a74779
    Romain Vimont authored
    The methods above_of(), left_of() and above_left_of() returned the
    matching block by value, or a default block if the offset resulted in a
    block outside boundaries.
    
    The Block structure is quite big (std::mem::size_of::<Block>() == 120).
    For reading a field, it is probably not optimal to return a whole Block
    copy or a new default block (although the compiler might optimize such
    accesses).
    
    Moreover, the boundaries checks were often redundant, because already
    done by the callers.
    
    Instead, let the callers check boundaries and return a reference to the
    matching block.
    86a74779