common: Clean up code

- Combine if condition with the same return value.
- Remove empty space
- Remove tab
This commit is contained in:
JunsuChoi 2021-02-16 11:19:19 +09:00 committed by Hermet Park
parent 6a4598f706
commit c63f961b9c
6 changed files with 27 additions and 34 deletions

View file

@ -54,10 +54,8 @@ struct Canvas::Impl
Result clear(bool free) Result clear(bool free)
{ {
if (!renderer) return Result::InsufficientCondition;
//Clear render target before drawing //Clear render target before drawing
if (!renderer->clear()) return Result::InsufficientCondition; if (!renderer || !renderer->clear()) return Result::InsufficientCondition;
//free paints //free paints
if (free) { if (free) {
@ -93,9 +91,7 @@ struct Canvas::Impl
Result draw() Result draw()
{ {
if (!renderer) return Result::InsufficientCondition; if (!renderer || !renderer->preRender()) return Result::InsufficientCondition;
if (!renderer->preRender()) return Result::InsufficientCondition;
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
if (!(*paint)->pImpl->render(*renderer)) return Result::InsufficientCondition; if (!(*paint)->pImpl->render(*renderer)) return Result::InsufficientCondition;

View file

@ -220,8 +220,7 @@ namespace tvg
bool composite(Paint* target, CompositeMethod method) bool composite(Paint* target, CompositeMethod method)
{ {
if (!target && method != CompositeMethod::None) return false; if ((!target && method != CompositeMethod::None) || (target && method == CompositeMethod::None)) return false;
if (target && method == CompositeMethod::None) return false;
cmpTarget = target; cmpTarget = target;
cmpMethod = method; cmpMethod = method;
return true; return true;

View file

@ -141,8 +141,7 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
const char *itr = buf, *itrEnd = buf + bufLength; const char *itr = buf, *itrEnd = buf + bufLength;
char* tmpBuf = (char*)alloca(bufLength + 1); char* tmpBuf = (char*)alloca(bufLength + 1);
if (!buf) return false; if (!buf || !func) return false;
if (!func) return false;
while (itr < itrEnd) { while (itr < itrEnd) {
const char* p = _simpleXmlSkipWhiteSpace(itr, itrEnd); const char* p = _simpleXmlSkipWhiteSpace(itr, itrEnd);
@ -200,8 +199,7 @@ bool simpleXmlParse(const char* buf, unsigned bufLength, bool strip, simpleXMLCb
{ {
const char *itr = buf, *itrEnd = buf + bufLength; const char *itr = buf, *itrEnd = buf + bufLength;
if (!buf) return false; if (!buf || !func) return false;
if (!func) return false;
#define CB(type, start, end) \ #define CB(type, start, end) \
do { \ do { \