[colobot] 16/100: Remove remaining occurences of "this == nullptr" (#828)
Didier Raboud
odyx at moszumanska.debian.org
Thu Jun 1 18:10:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 35d60aaae58b88d314dbe2501b5ee415490a1b96
Author: krzys-h <krzys_h at interia.pl>
Date: Fri Nov 11 19:45:57 2016 +0100
Remove remaining occurences of "this == nullptr" (#828)
---
src/CBot/CBotProgram.cpp | 3 +--
src/CBot/CBotStack.cpp | 17 +++++++++++++----
src/CBot/CBotToken.cpp | 6 +++---
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index 978c641..a303df6 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -363,8 +363,7 @@ bool CBotProgram::RestoreState(FILE* pf)
}
// retrieves the stack from the memory
- // uses a nullptr pointer (m_stack) but it's ok like that
- // TODO: no it's not okay like that! but it looks like it doesn't get optimized out at least ~krzys_h
+ m_stack = CBotStack::AllocateStack();
if (!m_stack->RestoreState(pf, m_stack)) return false;
m_stack->SetProgram(this); // bases for routines
diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index c554d7c..6afcc75 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -192,8 +192,18 @@ bool CBotStack::Return(CBotStack* pfils)
m_var = pfils->m_var; // result transmitted
pfils->m_var = nullptr; // not to destroy the variable
- if (m_next != nullptr) m_next->Delete();m_next = nullptr; // releases the stack above
- if (m_next2 != nullptr) m_next2->Delete();m_next2 = nullptr; // also the second stack (catch)
+ if (m_next != nullptr)
+ {
+ // releases the stack above
+ m_next->Delete();
+ m_next = nullptr;
+ }
+ if (m_next2 != nullptr)
+ {
+ // also the second stack (catch)
+ m_next2->Delete();
+ m_next2 = nullptr;
+ }
return IsOk(); // interrupted if error
}
@@ -731,8 +741,7 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
if (!ReadWord(pf, w)) return false;
if ( w == 0 ) return true; // 0 - terminator
- if ( this == nullptr ) pStack = AllocateStack();
- else pStack = AddStack();
+ pStack = AddStack();
if ( w == 2 ) // 2 - m_next2
{
diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp
index 890c038..28e6690 100644
--- a/src/CBot/CBotToken.cpp
+++ b/src/CBot/CBotToken.cpp
@@ -199,7 +199,7 @@ const CBotToken& CBotToken::operator=(const CBotToken& src)
////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetType()
{
- if (this == nullptr) return 0;
+ assert(this != nullptr);
if (m_type == TokenTypKeyWord) return m_keywordId;
return m_type;
}
@@ -225,14 +225,14 @@ void CBotToken::SetString(const std::string& name)
////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetStart()
{
- if (this == nullptr) return -1;
+ assert(this != nullptr);
return m_start;
}
////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetEnd()
{
- if (this == nullptr) return -1;
+ assert(this != nullptr);
return m_end;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list