BAGEL: Remove some useless initializations (value directly overwritten), reduce variable scopes

This commit is contained in:
Strangerke 2024-05-30 06:19:42 +01:00
parent a5c034763c
commit e06f7ebc3d
4 changed files with 9 additions and 20 deletions

View File

@ -27,7 +27,6 @@
#include "bagel/boflib/error.h"
#include "bagel/boflib/rect.h"
#include "bagel/boflib/string.h"
#include "bagel/boflib/vector.h"
namespace Bagel {

View File

@ -532,9 +532,8 @@ int CBagRPObject::runResiduePrintedQueue() {
return 0;
}
CBagRPObject *pRPObj = _pRPList->getNodeItem(0);
for (int i = 0; i < nCount; i++) {
pRPObj = _pRPList->getNodeItem(i);
CBagRPObject *pRPObj = _pRPList->getNodeItem(i);
// This could fail if we are not initialized properly
if (pRPObj->_bInitialized == false) {
@ -1498,10 +1497,9 @@ bool CBagRPObject::initialize() {
// Scoff the dossier out of the LOG_WLD SDEV. If it's not there then hurl.
bool bDoUntouched = (_pTouchedList != _pUntouchedList);
int nCount = _pTouchedList->getCount();
DossierObj *pDosObj = nullptr;
for (int i = 0; i < nCount; i++) {
pDosObj = _pTouchedList->getNodeItem(i);
DossierObj *pDosObj = _pTouchedList->getNodeItem(i);
pDosObj->_pDossier = (CBagDossierObject *)pSDev->getObject(pDosObj->_sDossier);
if (pDosObj->_pDossier == nullptr) {
return false;
@ -1516,7 +1514,7 @@ bool CBagRPObject::initialize() {
if (bDoUntouched) {
nCount = _pUntouchedList->getCount();
for (int i = 0; i < nCount; i++) {
pDosObj = _pUntouchedList->getNodeItem(i);
DossierObj *pDosObj = _pUntouchedList->getNodeItem(i);
pDosObj->_pDossier = (CBagDossierObject *)pSDev->getObject(pDosObj->_sDossier);
if (pDosObj->_pDossier == nullptr) {
return false;
@ -1624,12 +1622,10 @@ CBagDossierObject *CBagRPObject::getActiveDossier() {
// Used to set the currently active dossier when one is displayed to the user.
void CBagRPObject::setActiveDossier(CBagDossierObject *pDosObj) {
CBofList<DossierObj *> *pDosList = (_bTouched ? _pTouchedList : _pUntouchedList);
DossierObj *p = nullptr;
int nCount = pDosList->getCount();
for (int i = 0; i < nCount; i++) {
p = pDosList->getNodeItem(i);
DossierObj *p = pDosList->getNodeItem(i);
if (p->_pDossier == pDosObj) {
_nCurDossier = i;
saveResiduePrintedVars();
@ -1652,10 +1648,8 @@ DossierObj::~DossierObj() {
_pDossier = nullptr;
// Expressions, however, we do own
if (_xDosExp) {
delete _xDosExp;
_xDosExp = nullptr;
}
delete _xDosExp;
_xDosExp = nullptr;
}
} // namespace Bagel

View File

@ -210,7 +210,6 @@ ParseCodes CBagSpriteObject::setInfo(CBagIfstream &istr) {
ErrorCode CBagSpriteObject::update(CBofBitmap *pBmp, CBofPoint pt, CBofRect * /*pSrcRect*/, int) {
if (_xSprite) {
bool b = true;
int nFrameInterval = getFrameRate();
if (nFrameInterval != 0) {
@ -223,12 +222,12 @@ ErrorCode CBagSpriteObject::update(CBofBitmap *pBmp, CBofPoint pt, CBofRect * /*
}
}
b = _xSprite->paintSprite(pBmp, pt.x, pt.y);
bool bPaintResult = _xSprite->paintSprite(pBmp, pt.x, pt.y);
// Don't have to redraw this item...
// setDirty (false);
if (!b)
if (!bPaintResult)
return ERR_UNKNOWN;
}
return ERR_NONE;

View File

@ -275,9 +275,6 @@ CBofPoint CBagStorageDev::arrangeFloater(CBofPoint nPos, CBagObject *pObj) {
CBofPoint NextPos = nPos;
if (getBackground() != nullptr) {
int nPageNum = 0;
int nBackWidth = getBackground()->width();
int nBackHeight = getBackground()->height();
int nObjWidth = pObj->getRect().width();
@ -292,7 +289,7 @@ CBofPoint CBagStorageDev::arrangeFloater(CBofPoint nPos, CBagObject *pObj) {
// Always round this figure up...
nPageNum = ((NextPos.y + nObjHeight) / nBackHeight);
int nPageNum = ((NextPos.y + nObjHeight) / nBackHeight);
if (((NextPos.y + nObjHeight) % nBackHeight) != 0) {
nPageNum++;
}