Removed a few useless assignations and Tile copies

This commit is contained in:
Olivier Teulière 2012-02-19 12:49:58 +01:00
parent 66eec913c9
commit 038910e5df
2 changed files with 10 additions and 18 deletions

View file

@ -154,13 +154,12 @@ void Board::addRound(const Dictionary &iDic, const Round &iRound)
int col = iRound.getCoord().getCol();
if (iRound.getCoord().getDir() == Coord::HORIZONTAL)
{
Tile t;
for (unsigned int i = 0; i < iRound.getWordLen(); i++)
{
const Tile &t = iRound.getTile(i);
if (isVacant(row, col + i))
{
ASSERT(iRound.isPlayedFromRack(i), "Invalid round (1)");
t = iRound.getTile(i);
m_tilesRow[row][col + i] = t;
m_jokerRow[row][col + i] = iRound.isJoker(i);
m_tilesCol[col + i][row] = t;
@ -175,13 +174,12 @@ void Board::addRound(const Dictionary &iDic, const Round &iRound)
}
else
{
Tile t;
for (unsigned int i = 0; i < iRound.getWordLen(); i++)
{
const Tile &t = iRound.getTile(i);
if (isVacant(row + i, col))
{
ASSERT(iRound.isPlayedFromRack(i), "Invalid round (1)");
t = iRound.getTile(i);
m_tilesRow[row + i][col] = t;
m_jokerRow[row + i][col] = iRound.isJoker(i);
m_tilesCol[col][row + i] = t;
@ -222,10 +220,8 @@ void Board::removeRound(const Dictionary &iDic, const Round &iRound)
"Invalid round removal");
m_tilesRow[row][col + i] = Tile();
m_jokerRow[row][col + i] = false;
m_crossRow[row][col + i].setAny();
m_tilesCol[col + i][row] = Tile();
m_jokerCol[col + i][row] = false;
m_crossCol[col + i][row].setAny();
}
}
}
@ -241,13 +237,13 @@ void Board::removeRound(const Dictionary &iDic, const Round &iRound)
"Invalid round removal");
m_tilesRow[row + i][col] = Tile();
m_jokerRow[row + i][col] = false;
m_crossRow[row + i][col].setAny();
m_tilesCol[col][row + i] = Tile();
m_jokerCol[col][row + i] = false;
m_crossCol[col][row + i].setAny();
}
}
}
// Rebuild all the cross checks, because they are now invalid
buildCross(iDic);
#ifdef DEBUG
checkDouble();
@ -276,8 +272,6 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
const Matrix<bool> &iJokerMx,
Round &iRound) const
{
Tile t;
int l, p;
bool isolated = true;
int fromrack = 0;
@ -300,7 +294,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
for (unsigned int i = 0; i < iRound.getWordLen(); i++)
{
t = iRound.getTile(i);
const Tile &t = iRound.getTile(i);
if (!iTilesMx[row][col + i].isEmpty())
{
// Using a joker tile to emulate the letter on the board is not allowed,
@ -327,6 +321,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
if (!iCrossMx[row][col + i].isAny())
isolated = false;
int l;
if (!iRound.isJoker(i))
l = t.getPoints() * m_tileMultipliers[row][col + i];
else
@ -334,7 +329,7 @@ int Board::checkRoundAux(const Matrix<Tile> &iTilesMx,
pts += l;
wordmul *= m_wordMultipliers[row][col + i];
p = iPointsMx[row][col + i];
int p = iPointsMx[row][col + i];
if (p >= 0)
{
ptscross += (p + l) * m_wordMultipliers[row][col + i];

View file

@ -136,11 +136,10 @@ void BoardSearch::leftPart(Rack &iRack, Round &ioPartialWord,
if (iLimit > 0)
{
Tile l;
bool hasJokerInRack = iRack.in(Tile::Joker());
for (unsigned int succ = m_dic.getSucc(n); succ; succ = m_dic.getNext(succ))
{
l = Tile(m_dic.getChar(succ));
const Tile &l = Tile(m_dic.getChar(succ));
if (iRack.in(l))
{
iRack.remove(l);
@ -172,8 +171,6 @@ void BoardSearch::extendRight(Rack &iRack, Round &ioPartialWord,
Results &oResults, unsigned int iNode,
int iRow, int iCol, int iAnchor) const
{
Tile l;
if (m_tilesMx[iRow][iCol].isEmpty())
{
if (m_dic.isEndOfWord(iNode) && iCol > iAnchor)
@ -188,7 +185,7 @@ void BoardSearch::extendRight(Rack &iRack, Round &ioPartialWord,
bool hasJokerInRack = iRack.in(Tile::Joker());
for (unsigned int succ = m_dic.getSucc(iNode); succ; succ = m_dic.getNext(succ))
{
l = Tile(m_dic.getChar(succ));
const Tile &l = Tile(m_dic.getChar(succ));
if (m_crossMx[iRow][iCol].check(l))
{
if (iRack.in(l))
@ -214,7 +211,7 @@ void BoardSearch::extendRight(Rack &iRack, Round &ioPartialWord,
}
else
{
l = m_tilesMx[iRow][iCol];
const Tile &l = m_tilesMx[iRow][iCol];
wint_t upperChar = towupper(l.toChar());
for (unsigned int succ = m_dic.getSucc(iNode); succ ; succ = m_dic.getNext(succ))
{