From df24db5b588a4c90f0bd0dcece7662774cc19e97 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Sun, 30 Jan 2022 23:26:30 +0800 Subject: [PATCH] optimize nasal_import::check_import --- nasal_import.h | 19 ++++++++----------- nasal_vm.h | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/nasal_import.h b/nasal_import.h index 0563b9d..ca5715a 100644 --- a/nasal_import.h +++ b/nasal_import.h @@ -26,17 +26,14 @@ only this kind of node can be recognized as 'import': call_func string:'filename' */ - if(node.type()!=ast_call) - return false; - if(node.size()!=2) - return false; - if(node[0].str()!="import") - return false; - if(node[1].type()!=ast_callf) - return false; - if(node[1].size()!=1 || node[1][0].type()!=ast_str) - return false; - return true; + return ( + node.type()==ast_call && + node.size()==2 && + node[0].str()=="import" && + node[1].type()==ast_callf && + node[1].size()==1 && + node[1][0].type()==ast_str + ); } bool nasal_import::check_exist(const std::string& file) diff --git a/nasal_vm.h b/nasal_vm.h index e676f54..e43dfd2 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -118,7 +118,6 @@ public: const nasal_import&, const bool, const bool); - }; void nasal_vm::init(