diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-06-27 01:05:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 01:05:18 +0200 |
commit | eaaff9da3178fa515a0f051fda932c1dd04d53db (patch) | |
tree | 56173535c376e0324f89baccf4bc14b2580ead23 /modules/gdscript | |
parent | d8c96461183f0dc3208c3d624674fa4544212ea5 (diff) | |
parent | 4e5310cc60dc17e5ef09e57115ca8236544679e4 (diff) |
Merge pull request #29941 from qarmin/redundant_code_and_others
Remove redundant code, possible NULL pointers and others
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 9 | ||||
-rw-r--r-- | modules/gdscript/gdscript_tokenizer.cpp | 4 |
4 files changed, 7 insertions, 10 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 3fb9268702..95f3c12806 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -69,7 +69,7 @@ Variant GDScriptNativeClass::_new() { Object *o = instance(); if (!o) { ERR_EXPLAIN("Class type: '" + String(name) + "' is not instantiable."); - ERR_FAIL_COND_V(!o, Variant()); + ERR_FAIL_V(Variant()); } Reference *ref = Object::cast_to<Reference>(o); diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 189317b163..caffe04700 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -1073,7 +1073,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int set_index; bool named = false; - if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { + if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name); named = true; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index e4d606fceb..85b270b369 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1149,7 +1149,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (!expr) { ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is..."); - ERR_FAIL_COND_V(!expr, NULL); + ERR_FAIL_V(NULL); } /******************/ @@ -1492,7 +1492,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (next_op == -1) { _set_error("Yet another parser bug...."); - ERR_FAIL_COND_V(next_op == -1, NULL); + ERR_FAIL_V(NULL); } // OK! create operator.. @@ -5943,11 +5943,8 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data if (p_container.kind == DataType::BUILTIN && p_container.builtin_type == Variant::OBJECT) { // Object built-in is a special case, it's compatible with any object and with null - if (p_expression.kind == DataType::BUILTIN && p_expression.builtin_type == Variant::NIL) { - return true; - } if (p_expression.kind == DataType::BUILTIN) { - return false; + return p_expression.builtin_type == Variant::NIL; } // If it's not a built-in, must be an object return true; diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index a93d1ceebb..95715ab648 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -1189,7 +1189,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) int version = decode_uint32(&buf[4]); if (version > BYTECODE_VERSION) { ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version."); - ERR_FAIL_COND_V(version > BYTECODE_VERSION, ERR_INVALID_DATA); + ERR_FAIL_V(ERR_INVALID_DATA); } int identifier_count = decode_uint32(&buf[8]); int constant_count = decode_uint32(&buf[12]); @@ -1303,7 +1303,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) } break; case TK_CONSTANT: { - Variant c = tt.get_token_constant(); + const Variant &c = tt.get_token_constant(); if (!constant_map.has(c)) { int idx = constant_map.size(); constant_map[c] = idx; |