From a8feaa53ccb08ac2c416896b4ce7fd4147b9c2cc Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 10 Oct 2014 20:39:38 -0400 Subject: [PATCH] src: remove useless comparisons on null Signed-off-by: Jean Privat --- lib/opts.nit | 6 +----- src/compiler/global_compiler.nit | 2 +- src/doc/doc_model.nit | 8 ++------ src/ffi/java.nit | 1 - src/interpreter/naive_interpreter.nit | 2 +- src/nitserial.nit | 2 +- src/semantize/auto_super_init.nit | 1 - src/testing/testing_doc.nit | 1 - src/toolcontext.nit | 2 +- src/vm.nit | 1 - 10 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/opts.nit b/lib/opts.nit index a1bffc1..c088325 100644 --- a/lib/opts.nit +++ b/lib/opts.nit @@ -194,11 +194,7 @@ class OptionEnum redef fun pretty_default do - if default_value != null then - return " ({values[default_value]})" - else - return "" - end + return " ({values[default_value]})" end end diff --git a/src/compiler/global_compiler.nit b/src/compiler/global_compiler.nit index 2196071..b8eef9b 100644 --- a/src/compiler/global_compiler.nit +++ b/src/compiler/global_compiler.nit @@ -342,7 +342,7 @@ class GlobalCompilerVisitor var valtype = value.mtype.as(MClassType) var res = self.new_var(mtype) - if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(value.mtype.as(MClassType)) then + if not compiler.runtime_type_analysis.live_types.has(value.mtype.as(MClassType)) then self.add("/*no boxing of {value.mtype}: {value.mtype} is not live! */") self.add("PRINT_ERROR(\"Dead code executed!\\n\"); show_backtrace(1);") return res diff --git a/src/doc/doc_model.nit b/src/doc/doc_model.nit index f13d69f..41386d2 100644 --- a/src/doc/doc_model.nit +++ b/src/doc/doc_model.nit @@ -190,12 +190,8 @@ redef class MGroup redef fun tpl_namespace do var tpl = new Template - if mproject != null then - tpl.add mproject.tpl_namespace - else if parent != null then - tpl.add parent.tpl_namespace - end - if mproject != null and mproject.root != self then + tpl.add mproject.tpl_namespace + if mproject.root != self then tpl.add "::" tpl.add tpl_link end diff --git a/src/ffi/java.nit b/src/ffi/java.nit index 7be54ce..3257a60 100644 --- a/src/ffi/java.nit +++ b/src/ffi/java.nit @@ -271,7 +271,6 @@ redef class AMethPropdef private fun insert_artificial_callbacks(toolcontext: ToolContext) do var fcc = foreign_callbacks - assert fcc != null var modelbuilder = toolcontext.modelbuilder var mmodule = mpropdef.mclassdef.mmodule diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 92b658d..9495d3f 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -750,7 +750,7 @@ redef class AMethPropdef else if pname == "is_same_type" then return v.bool_instance(args[0].mtype == args[1].mtype) else if pname == "is_same_instance" then - return v.bool_instance(args[1] != null and args[0].eq_is(args[1])) + return v.bool_instance(args[0].eq_is(args[1])) else if pname == "exit" then exit(args[1].to_i) abort diff --git a/src/nitserial.nit b/src/nitserial.nit index 5ad0aed..2fd0f82 100644 --- a/src/nitserial.nit +++ b/src/nitserial.nit @@ -53,7 +53,7 @@ class NitModule if header != null then add header var name = name - if name != null then add "module {name}\n\n" + add "module {name}\n\n" for i in imports do add "import {i}\n" add "\n" diff --git a/src/semantize/auto_super_init.nit b/src/semantize/auto_super_init.nit index 95b2acb..e6feb5c 100644 --- a/src/semantize/auto_super_init.nit +++ b/src/semantize/auto_super_init.nit @@ -210,7 +210,6 @@ redef class ASendExpr redef fun accept_auto_super_init(v) do var mproperty = self.callsite.mproperty - if mproperty == null then return if mproperty.is_init then v.has_explicit_super_init = self end diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index f543a2b..566e014 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -200,7 +200,6 @@ redef class ModelBuilder if not mmodule2nmodule.has_key(mmodule) then return ts var nmodule = mmodule2nmodule[mmodule] - assert nmodule != null # usualy, only the original module must be imported in the unit test. var o = mmodule diff --git a/src/toolcontext.nit b/src/toolcontext.nit index 893a843..05c88fb 100644 --- a/src/toolcontext.nit +++ b/src/toolcontext.nit @@ -438,7 +438,7 @@ class BashCompletion addn " COMPREPLY=()" addn " cur=\"$\{COMP_WORDS[COMP_CWORD]\}\"" addn " prev=\"$\{COMP_WORDS[COMP_CWORD-1]\}\"" - if option_names != null then + if not option_names.is_empty then addn " opts=\"{option_names.join(" ")}\"" addn " if [[ $\{cur\} == -* ]] ; then" addn " COMPREPLY=( $(compgen -W \"$\{opts\}\" -- $\{cur\}) )" diff --git a/src/vm.nit b/src/vm.nit index 0779a6a..3807ab7 100644 --- a/src/vm.nit +++ b/src/vm.nit @@ -106,7 +106,6 @@ class VirtualMachine super NaiveInterpreter # Sub can be discovered inside a Generic type during the subtyping test if not sub.mclass.loaded then create_class(sub.mclass) - if anchor == null then anchor = sub if sup isa MGenericType then var sub2 = sub.supertype_to(mainmodule, anchor, sup.mclass) assert sub2.mclass == sup.mclass -- 1.7.9.5