optimize nasal_import::check_import

This commit is contained in:
ValKmjolnir 2022-01-30 23:26:30 +08:00
parent 4def93b4ad
commit df24db5b58
2 changed files with 8 additions and 12 deletions

View File

@ -26,17 +26,14 @@ only this kind of node can be recognized as 'import':
call_func call_func
string:'filename' string:'filename'
*/ */
if(node.type()!=ast_call) return (
return false; node.type()==ast_call &&
if(node.size()!=2) node.size()==2 &&
return false; node[0].str()=="import" &&
if(node[0].str()!="import") node[1].type()==ast_callf &&
return false; node[1].size()==1 &&
if(node[1].type()!=ast_callf) node[1][0].type()==ast_str
return false; );
if(node[1].size()!=1 || node[1][0].type()!=ast_str)
return false;
return true;
} }
bool nasal_import::check_exist(const std::string& file) bool nasal_import::check_exist(const std::string& file)

View File

@ -118,7 +118,6 @@ public:
const nasal_import&, const nasal_import&,
const bool, const bool,
const bool); const bool);
}; };
void nasal_vm::init( void nasal_vm::init(