Pārlūkot izejas kodu

ncd: small optimization

ambrop7 13 gadi atpakaļ
vecāks
revīzija
becfbd8014
3 mainītis faili ar 9 papildinājumiem un 25 dzēšanām
  1. 7 7
      ncd/NCDInterpreter.c
  2. 0 8
      ncd/NCDModule.c
  3. 2 10
      ncd/NCDModule.h

+ 7 - 7
ncd/NCDInterpreter.c

@@ -1073,12 +1073,12 @@ void statement_instance_func_event (NCDModuleInst *inst, int event)
         } break;
         
         case NCDMODULE_EVENT_DEAD: {
-            int is_error = NCDModuleInst_HaveError(&ps->inst);
-            
-            if (is_error) {
-                statement_log(ps, BLOG_ERROR, "died with error");
-            } else {
-                statement_log(ps, BLOG_INFO, "died");
+            if (BLog_WouldLog(BLOG_INFO, BLOG_CURRENT_CHANNEL)) {
+                if (ps->inst.is_error) {
+                    statement_log(ps, BLOG_ERROR, "died with error");
+                } else {
+                    statement_log(ps, BLOG_INFO, "died");
+                }
             }
             
             // free instance
@@ -1091,7 +1091,7 @@ void statement_instance_func_event (NCDModuleInst *inst, int event)
             ps->inst.istate = SSTATE_FORGOTTEN;
             
             // set error
-            if (is_error && ps->i < p->ap) {
+            if (ps->inst.is_error && ps->i < p->ap) {
                 p->error = 1;
             }
             

+ 0 - 8
ncd/NCDModule.c

@@ -196,14 +196,6 @@ static int object_func_getobj (NCDModuleInst *n, NCD_string_id_t name, NCDObject
     return res;
 }
 
-int NCDModuleInst_HaveError (NCDModuleInst *n)
-{
-    DebugObject_Access(&n->d_obj);
-    ASSERT(n->state == STATE_DEAD)
-    
-    return n->is_error;
-}
-
 void * NCDModuleInst_Backend_GetUser (NCDModuleInst *n)
 {
     DebugObject_Access(&n->d_obj);

+ 2 - 10
ncd/NCDModule.h

@@ -70,7 +70,8 @@ struct NCDModuleProcess_s;
  *   {@link NCDModuleInst_Clean} or {@link NCDModuleInst_Die}, unless
  *   the module goes up again.
  * 
- * - NCDMODULE_EVENT_DEAD: the module died.
+ * - NCDMODULE_EVENT_DEAD: the module died. To determine if the module
+ *   died with error, read the is_error member of {@link NCDModuleInst}.
  *   The instance enters dead state.
  * 
  * This function is not being called in event context. The interpreter should
@@ -431,15 +432,6 @@ void NCDModuleInst_Clean (NCDModuleInst *n);
  */
 NCDObject NCDModuleInst_Object (NCDModuleInst *n);
 
-/**
- * Checks whether the module terminated unsuccessfully.
- * The instance must be in dead state.
- * 
- * @param n the instance
- * @return 1 if module terminated unsuccessfully, 0 if successfully
- */
-int NCDModuleInst_HaveError (NCDModuleInst *n);
-
 /**
  * Retuns the state pointer passed to handlers of a module backend instance;
  * see {@link NCDModule_func_new2}.