From 6d6c54d894686832f7e563933b42689af6aead04 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Mon, 8 Jul 2024 09:50:27 +0200 Subject: [PATCH] style: remove duplicate nil checking procedures --- engine/vm.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/engine/vm.go b/engine/vm.go index da788eb..5575ed0 100644 --- a/engine/vm.go +++ b/engine/vm.go @@ -76,73 +76,46 @@ type VM struct { // Register0 registers a predicate of arity 0. func (vm *VM) Register0(name Atom, p Predicate0) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 0}, p) } // Register1 registers a predicate of arity 1. func (vm *VM) Register1(name Atom, p Predicate1) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 1}, p) } // Register2 registers a predicate of arity 2. func (vm *VM) Register2(name Atom, p Predicate2) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 2}, p) } // Register3 registers a predicate of arity 3. func (vm *VM) Register3(name Atom, p Predicate3) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 3}, p) } // Register4 registers a predicate of arity 4. func (vm *VM) Register4(name Atom, p Predicate4) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 4}, p) } // Register5 registers a predicate of arity 5. func (vm *VM) Register5(name Atom, p Predicate5) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 5}, p) } // Register6 registers a predicate of arity 6. func (vm *VM) Register6(name Atom, p Predicate6) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 6}, p) } // Register7 registers a predicate of arity 7. func (vm *VM) Register7(name Atom, p Predicate7) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 7}, p) } // Register8 registers a predicate of arity 8. func (vm *VM) Register8(name Atom, p Predicate8) { - if vm.procedures == nil { - vm.procedures = orderedmap.New[procedureIndicator, procedure]() - } vm.setProcedure(procedureIndicator{name: name, arity: 8}, p) }