Selaa lähdekoodia

ncd: NCDAst: remove unused NCDValue_Compare

ambrop7 13 vuotta sitten
vanhempi
sitoutus
cdc19fc296
2 muutettua tiedostoa jossa 0 lisäystä ja 92 poistoa
  1. 0 91
      ncd/NCDAst.c
  2. 0 1
      ncd/NCDAst.h

+ 0 - 91
ncd/NCDAst.c

@@ -352,97 +352,6 @@ const char * NCDValue_VarName (NCDValue *o)
     return o->var_name;
 }
 
-int NCDValue_Compare (NCDValue *o, NCDValue *v)
-{
-    value_assert(o);
-    value_assert(v);
-    
-    int cmp = (o->type > v->type) - (o->type < v->type);
-    if (cmp) {
-        return cmp;
-    }
-    
-    ASSERT(o->type == v->type)
-    
-    if (o->type == NCDVALUE_STRING) {
-        size_t min_len = o->string_len < v->string_len ? o->string_len : v->string_len;
-        
-        int cmp = memcmp(o->string, v->string, min_len);
-        if (cmp) {
-            return (cmp > 0) - (cmp < 0);
-        }
-        
-        return (o->string_len > v->string_len) - (o->string_len < v->string_len);
-    }
-    
-    if (o->type == NCDVALUE_LIST) {
-        NCDValue *x = NCDValue_ListFirst(o);
-        NCDValue *y = NCDValue_ListFirst(v);
-        
-        while (1) {
-            if (!x && y) {
-                return -1;
-            }
-            if (x && !y) {
-                return 1;
-            }
-            if (!x && !y) {
-                return 0;
-            }
-            
-            int res = NCDValue_Compare(x, y);
-            if (res) {
-                return res;
-            }
-            
-            x = NCDValue_ListNext(o, x);
-            y = NCDValue_ListNext(v, y);
-        }
-    }
-    
-    if (o->type == NCDVALUE_MAP) {
-        NCDValue *key1 = NCDValue_MapFirstKey(o);
-        NCDValue *key2 = NCDValue_MapFirstKey(v);
-        
-        while (1) {
-            if (!key1 && key2) {
-                return -1;
-            }
-            if (key1 && !key2) {
-                return 1;
-            }
-            if (!key1 && !key2) {
-                return 0;
-            }
-            
-            int res = NCDValue_Compare(key1, key2);
-            if (res) {
-                return res;
-            }
-            
-            NCDValue *val1 = NCDValue_MapKeyValue(o, key1);
-            NCDValue *val2 = NCDValue_MapKeyValue(v, key2);
-            
-            res = NCDValue_Compare(val1, val2);
-            if (res) {
-                return res;
-            }
-            
-            key1 = NCDValue_MapNextKey(o, key1);
-            key2 = NCDValue_MapNextKey(v, key2);
-        }
-    }
-    
-    if (o->type == NCDVALUE_VAR) {
-        int res = strcmp(o->var_name, v->var_name);
-        
-        return (res > 0) - (res < 0);
-    }
-    
-    ASSERT(0)
-    return 0;
-}
-
 void NCDProgram_Init (NCDProgram *o)
 {
     LinkedList1_Init(&o->processes_list);

+ 0 - 1
ncd/NCDAst.h

@@ -160,7 +160,6 @@ NCDValue * NCDValue_MapNextKey (NCDValue *o, NCDValue *ekey);
 NCDValue * NCDValue_MapKeyValue (NCDValue *o, NCDValue *ekey);
 int NCDValue_InitVar (NCDValue *o, const char *var_name) WARN_UNUSED;
 const char * NCDValue_VarName (NCDValue *o);
-int NCDValue_Compare (NCDValue *o, NCDValue *v);
 
 void NCDProgram_Init (NCDProgram *o);
 void NCDProgram_Free (NCDProgram *o);