Skip to content

Commit

Permalink
[共通] Grid::resize(w, 0) で w を保存する #989
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Apr 8, 2023
1 parent 4a1ea87 commit ec9ff21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions Siv3D/include/Siv3D/detail/Grid.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -609,19 +609,20 @@ namespace s3d
template <class Type, class Allocator>
inline void Grid<Type, Allocator>::resize(const size_type w, const size_type h)
{
const size_t oldWidth = m_width;
const size_t newWidth = w;
const size_t oldHeight = m_height;
const size_t newHeight = h;

// 幅か高さが 0 なら空の二次元配列にする
if ((newWidth == 0) || (newHeight == 0))
if ((w == 0) || (h == 0))
{
m_data.clear();
m_width = m_height = 0;
m_width = w;
m_height = h;
return;
}

const size_t oldWidth = m_width;
const size_t newWidth = w;
const size_t oldHeight = m_height;
const size_t newHeight = h;

// 元のサイズが 0 なら
if (m_data.isEmpty())
{
Expand Down Expand Up @@ -687,19 +688,20 @@ namespace s3d
template <class Type, class Allocator>
inline void Grid<Type, Allocator>::resize(const size_type w, const size_type h, const value_type& value)
{
const size_t oldWidth = m_width;
const size_t newWidth = w;
const size_t oldHeight = m_height;
const size_t newHeight = h;

// 幅か高さが 0 なら空の二次元配列にする
if ((newWidth == 0) || (newHeight == 0))
if ((w == 0) || (h == 0))
{
m_data.clear();
m_width = m_height = 0;
m_width = w;
m_height = h;
return;
}

const size_t oldWidth = m_width;
const size_t newWidth = w;
const size_t oldHeight = m_height;
const size_t newHeight = h;

// 元のサイズが 0 なら
if (m_data.isEmpty())
{
Expand Down
2 changes: 1 addition & 1 deletion Siv3D/src/Siv3D/SimpleTable/SivSimpleTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace s3d

void SimpleTable::clear()
{
m_grid = Grid<Item>(m_minColumnWidths.size(), 0);
m_grid.resize(m_minColumnWidths.size(), 0);

m_columnWidths = m_minColumnWidths;

Expand Down

0 comments on commit ec9ff21

Please sign in to comment.