Undefine yspec namespace optimzation
Partly fix yspec namespace optimization but some issues remain
This commit is contained in:
parent
b09e326307
commit
fa62eb0872
4 changed files with 34 additions and 18 deletions
|
|
@ -238,7 +238,7 @@
|
||||||
*
|
*
|
||||||
* see yang_find_module_by_namespace
|
* see yang_find_module_by_namespace
|
||||||
*/
|
*/
|
||||||
#define OPTIMIZE_YSPEC_NAMESPACE
|
#undef OPTIMIZE_YSPEC_NAMESPACE
|
||||||
|
|
||||||
/*! If set, make optimization of non-presence default container
|
/*! If set, make optimization of non-presence default container
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -171,9 +171,9 @@ str2ptr_search1(const map_str2ptr *mptab,
|
||||||
mp = &mptab[mid];
|
mp = &mptab[mid];
|
||||||
if ((cmp = clicon_strcmp(str, mp->mp_str)) == 0){
|
if ((cmp = clicon_strcmp(str, mp->mp_str)) == 0){
|
||||||
i = mid;
|
i = mid;
|
||||||
while (i >= 0 && clicon_strcmp(str, mptab[i].mp_str) == 0){
|
while (i < len && clicon_strcmp(str, mptab[i].mp_str) == 0){
|
||||||
mp = &mptab[i];
|
mp = &mptab[i];
|
||||||
i--;
|
i++;
|
||||||
}
|
}
|
||||||
*found = (map_str2ptr *)mp;
|
*found = (map_str2ptr *)mp;
|
||||||
return 1; /* found */
|
return 1; /* found */
|
||||||
|
|
@ -232,17 +232,26 @@ str2ptr_qsort(const void* arg1,
|
||||||
map_str2ptr *mp1 = (map_str2ptr*)arg1;
|
map_str2ptr *mp1 = (map_str2ptr*)arg1;
|
||||||
map_str2ptr *mp2 = (map_str2ptr*)arg2;
|
map_str2ptr *mp2 = (map_str2ptr*)arg2;
|
||||||
int eq;
|
int eq;
|
||||||
yang_stmt *yrev;
|
yang_stmt *yp;
|
||||||
char *rev1 = NULL;
|
yang_stmt *y;
|
||||||
char *rev2 = NULL;
|
int i;
|
||||||
|
int i1 = -1;
|
||||||
|
int i2 = -1;
|
||||||
|
|
||||||
eq = clicon_strcmp(mp1->mp_str, mp2->mp_str);
|
eq = clicon_strcmp(mp1->mp_str, mp2->mp_str);
|
||||||
if (0 && eq == 0){
|
if (eq == 0 && mp1->mp_ptr){
|
||||||
if ((yrev = yang_find(mp1->mp_ptr, Y_REVISION, NULL)) != NULL)
|
yp = yang_parent_get(mp1->mp_ptr);
|
||||||
rev1 = yang_argument_get(yrev);
|
i = 0;
|
||||||
if ((yrev = yang_find(mp2->mp_ptr, Y_REVISION, NULL)) != NULL)
|
while ((y = yn_iter(yp, &i)) != NULL){
|
||||||
rev2 = yang_argument_get(yrev);
|
if (y == mp1->mp_ptr)
|
||||||
eq = clicon_strcmp(rev1, rev2);
|
i1 = i;
|
||||||
|
else if (y == mp2->mp_ptr)
|
||||||
|
i2 = i;
|
||||||
|
if (i1 >= 0 && i2 >= 0){
|
||||||
|
eq = i1 < i2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return eq;
|
return eq;
|
||||||
}
|
}
|
||||||
|
|
@ -273,6 +282,12 @@ clixon_str2ptr(map_str2ptr *mptab,
|
||||||
return NULL; /* not found */
|
return NULL; /* not found */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Print a str2ptr map
|
||||||
|
*
|
||||||
|
* @param[in] f FILE
|
||||||
|
* @param[in] mptab String to ptr map
|
||||||
|
* @retval 0 OK
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
clixon_str2ptr_print(FILE *f,
|
clixon_str2ptr_print(FILE *f,
|
||||||
map_str2ptr *mptab)
|
map_str2ptr *mptab)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@ struct yang_stmt {
|
||||||
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
|
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
|
||||||
struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
||||||
char *ys_argument; /* String / argument depending on keyword */
|
char *ys_argument; /* String / argument depending on keyword */
|
||||||
/* XXX: can we move this to union, No SPEC is already there */
|
|
||||||
cg_var *ys_cv; /* cligen variable. See ys_populate()
|
cg_var *ys_cv; /* cligen variable. See ys_populate()
|
||||||
Following stmts have cv:s:
|
Following stmts have cv:s:
|
||||||
Y_FEATURE: boolean true or false
|
Y_FEATURE: boolean true or false
|
||||||
|
|
|
||||||
|
|
@ -2134,7 +2134,7 @@ yspec_nscache_get(yang_stmt *yspec,
|
||||||
if (yspec_nscache_new(yspec) < 0)
|
if (yspec_nscache_new(yspec) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return clixon_str2ptr(yspec->ys_nscache, ns, yang_len_get(yspec)+1);
|
return clixon_str2ptr(yspec->ys_nscache, ns, yang_len_get(yspec));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -2146,9 +2146,11 @@ yspec_nscache_new(yang_stmt *yspec)
|
||||||
map_str2ptr *mp;
|
map_str2ptr *mp;
|
||||||
yang_stmt *ym;
|
yang_stmt *ym;
|
||||||
int i;
|
int i;
|
||||||
|
size_t sz;
|
||||||
|
|
||||||
yspec_nscache_clear(yspec);
|
yspec_nscache_clear(yspec);
|
||||||
if ((yspec->ys_nscache = calloc(yang_len_get(yspec)+1, sizeof(*yspec->ys_nscache))) == NULL){
|
sz = sizeof(*yspec->ys_nscache);
|
||||||
|
if ((yspec->ys_nscache = calloc(yang_len_get(yspec)+1, sz)) == NULL){
|
||||||
clixon_err(OE_UNIX, errno, "calloc");
|
clixon_err(OE_UNIX, errno, "calloc");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -2160,7 +2162,7 @@ yspec_nscache_new(yang_stmt *yspec)
|
||||||
mp->mp_str = yang_find_mynamespace(ym);
|
mp->mp_str = yang_find_mynamespace(ym);
|
||||||
mp->mp_ptr = ym;
|
mp->mp_ptr = ym;
|
||||||
}
|
}
|
||||||
clixon_str2ptr_sort(yspec->ys_nscache, yang_len_get(yspec)+1);
|
clixon_str2ptr_sort(yspec->ys_nscache, yang_len_get(yspec));
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue