src: remove useless comparisons on null
authorJean Privat <jean@pryen.org>
Sat, 11 Oct 2014 00:39:38 +0000 (20:39 -0400)
committerJean Privat <jean@pryen.org>
Sat, 11 Oct 2014 17:23:01 +0000 (13:23 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/opts.nit
src/compiler/global_compiler.nit
src/doc/doc_model.nit
src/ffi/java.nit
src/interpreter/naive_interpreter.nit
src/nitserial.nit
src/semantize/auto_super_init.nit
src/testing/testing_doc.nit
src/toolcontext.nit
src/vm.nit

index a1bffc1..c088325 100644 (file)
@@ -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
 
index 2196071..b8eef9b 100644 (file)
@@ -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
index f13d69f..41386d2 100644 (file)
@@ -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
index 7be54ce..3257a60 100644 (file)
@@ -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
index 92b658d..9495d3f 100644 (file)
@@ -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
index 5ad0aed..2fd0f82 100644 (file)
@@ -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"
index 95b2acb..e6feb5c 100644 (file)
@@ -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
index f543a2b..566e014 100644 (file)
@@ -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
index 893a843..05c88fb 100644 (file)
@@ -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\}) )"
index 0779a6a..3807ab7 100644 (file)
@@ -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