Changeset 1136


Ignore:
Timestamp:
Feb 24, 2008, 12:46:31 AM (16 years ago)
Author:
Peter
Message:

avoid reallocation when sizes match in Vector assignment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/Vector.cc

    r1135 r1136  
    172172      return *this;
    173173    }
    174     delete_allocated_memory();
    175     vec_ = create_gsl_vector_copy(other);
     174    if (size()==other.size()){
     175      if (gsl_vector_memcpy(vec_, other.gsl_vector_p()))
     176        throw utility::GSL_error("Vector::assign memcpy failed");
     177    }
     178    else {
     179      delete_allocated_memory();
     180      vec_ = create_gsl_vector_copy(other);
     181    }
    176182    const_vec_ = vec_;
    177183    return *this;
Note: See TracChangeset for help on using the changeset viewer.