Don't resize util::array if size didn't change
This commit is contained in:
parent
1af6f26e80
commit
1b075bf40c
1 changed files with 6 additions and 0 deletions
|
|
@ -383,6 +383,9 @@ namespace psemek::util
|
|||
template <typename T, std::size_t N>
|
||||
void array<T, N>::resize(dims_type const & dims)
|
||||
{
|
||||
if (dims == dims_)
|
||||
return;
|
||||
|
||||
std::unique_ptr<T[]> data(new T[detail::product(dims)]);
|
||||
resize_impl(std::move(data), dims);
|
||||
}
|
||||
|
|
@ -390,6 +393,9 @@ namespace psemek::util
|
|||
template <typename T, std::size_t N>
|
||||
void array<T, N>::resize(dims_type const & dims, T const & value)
|
||||
{
|
||||
if (dims == dims_)
|
||||
return;
|
||||
|
||||
auto const size = detail::product(dims);
|
||||
std::unique_ptr<T[]> data(new T[size]);
|
||||
std::fill(data.get(), data.get() + size, value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue