Removed and enabled code for compile options: RESTART_PLUGIN_RPC, XML_NEW_DIFFERENTIATE, OPTIMIZE_45_BIND and OPTIMIZE_45_SORT
This commit is contained in:
parent
a3b6ea9e10
commit
29235d5547
9 changed files with 27 additions and 112 deletions
|
|
@ -158,6 +158,7 @@ struct search_index{
|
|||
* - Local name: In either case the "local name" is N (also "prefix")
|
||||
* It is this combination of the universally managed URI namespace with the
|
||||
* vocabulary's local names that is effective in avoiding name clashes.
|
||||
* @see struct xmlbody For XML body and attributes
|
||||
*/
|
||||
struct xml{
|
||||
enum cxobj_type x_type; /* type of node: element, attribute, body */
|
||||
|
|
@ -186,9 +187,8 @@ struct xml{
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef XML_NEW_DIFFERENTIATE
|
||||
/* This is experimental variant of struct xml for use by non-elements to save space
|
||||
/* Variant of struct xml for use by non-elements to save space
|
||||
* @see struct xml For XML elements
|
||||
*/
|
||||
struct xmlbody{
|
||||
enum cxobj_type xb_type; /* type of node: element, attribute, body */
|
||||
|
|
@ -201,7 +201,6 @@ struct xmlbody{
|
|||
see xml_enumerate and xml_cmp */
|
||||
cbuf *xb_value_cb; /* attribute and body nodes have values */
|
||||
};
|
||||
#endif /* XML_NEW_DIFFERENTIATE */
|
||||
|
||||
/*
|
||||
* Variables
|
||||
|
|
@ -277,11 +276,7 @@ xml_stats_one(cxobj *x,
|
|||
break;
|
||||
case CX_BODY:
|
||||
case CX_ATTR:
|
||||
#ifdef XML_NEW_DIFFERENTIATE
|
||||
sz += sizeof(struct xmlbody);
|
||||
#else
|
||||
sz += sizeof(struct xml);
|
||||
#endif
|
||||
if (x->x_value_cb)
|
||||
sz += cbuf_buflen(x->x_value_cb);
|
||||
break;
|
||||
|
|
@ -1042,10 +1037,9 @@ xml_childvec_get(cxobj *x)
|
|||
* ...
|
||||
* xml_free(x);
|
||||
* @endcode
|
||||
* @note Differentiates between body/attribute vs element to reduce mem allocation
|
||||
* @see xml_sort_insert
|
||||
*/
|
||||
#ifdef XML_NEW_DIFFERENTIATE
|
||||
/* Differentiate creating XML object body/element vs elenmet to reduce space */
|
||||
cxobj *
|
||||
xml_new(char *name,
|
||||
cxobj *xp,
|
||||
|
|
@ -1085,35 +1079,6 @@ xml_new(char *name,
|
|||
return x;
|
||||
}
|
||||
|
||||
#else /* XML_NEW_DIFFERENTIATE */
|
||||
|
||||
cxobj *
|
||||
xml_new(char *name,
|
||||
cxobj *xp,
|
||||
enum cxobj_type type)
|
||||
{
|
||||
cxobj *x;
|
||||
|
||||
if ((x = malloc(sizeof(cxobj))) == NULL){
|
||||
clicon_err(OE_XML, errno, "malloc");
|
||||
return NULL;
|
||||
}
|
||||
memset(x, 0, sizeof(cxobj));
|
||||
xml_type_set(x, type);
|
||||
if (name != NULL &&
|
||||
xml_name_set(x, name) < 0)
|
||||
return NULL;
|
||||
if (xp){
|
||||
xml_parent_set(x, xp);
|
||||
if (xml_child_append(xp, x) < 0)
|
||||
return NULL;
|
||||
x->_x_i = xml_child_nr(xp)-1;
|
||||
}
|
||||
_stats_nr++;
|
||||
return x;
|
||||
}
|
||||
#endif /* XML_NEW_DIFFERENTIATE */
|
||||
|
||||
/*! Create a new XML node and set it's body to a value
|
||||
*
|
||||
* @param[in] name The name of the new node
|
||||
|
|
|
|||
|
|
@ -128,9 +128,7 @@ strip_whitespace(cxobj *xt)
|
|||
*/
|
||||
static int
|
||||
populate_self_parent(cxobj *xt,
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
cxobj *xsibling,
|
||||
#endif
|
||||
cxobj **xerr)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -143,14 +141,12 @@ populate_self_parent(cxobj *xt,
|
|||
cbuf *cb = NULL;
|
||||
|
||||
name = xml_name(xt);
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
/* optimization for massive lists - use the first element as role model */
|
||||
if (xsibling &&
|
||||
xml_child_nr_type(xt, CX_ATTR) == 0){
|
||||
y = xml_spec(xsibling);
|
||||
goto set;
|
||||
}
|
||||
#endif
|
||||
xp = xml_parent(xt);
|
||||
if (xp == NULL){
|
||||
if (xerr &&
|
||||
|
|
@ -202,9 +198,7 @@ populate_self_parent(cxobj *xt,
|
|||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
set:
|
||||
#endif
|
||||
xml_spec_set(xt, y);
|
||||
#ifdef XML_EXPLICIT_INDEX
|
||||
if (xml_search_index_p(xt))
|
||||
|
|
@ -354,7 +348,6 @@ xml_bind_yang(cxobj *xt,
|
|||
goto done;
|
||||
}
|
||||
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
int
|
||||
xml_bind_yang0_opt(cxobj *xt,
|
||||
yang_bind yb,
|
||||
|
|
@ -424,8 +417,6 @@ xml_bind_yang0_opt(cxobj *xt,
|
|||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
#endif /* OPTIMIZE_45_BIND */
|
||||
|
||||
|
||||
/*! Find yang spec association of tree of XML nodes
|
||||
*
|
||||
|
|
@ -455,11 +446,7 @@ xml_bind_yang0(cxobj *xt,
|
|||
goto done;
|
||||
break;
|
||||
case YB_PARENT:
|
||||
if ((ret = populate_self_parent(xt,
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
NULL,
|
||||
#endif
|
||||
xerr)) < 0)
|
||||
if ((ret = populate_self_parent(xt, NULL, xerr)) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case YB_NONE:
|
||||
|
|
@ -477,13 +464,8 @@ xml_bind_yang0(cxobj *xt,
|
|||
strip_whitespace(xt);
|
||||
xc = NULL; /* Apply on children */
|
||||
while ((xc = xml_child_each(xt, xc, CX_ELMNT)) != NULL) {
|
||||
#ifdef OPTIMIZE_45_BIND
|
||||
if ((ret = xml_bind_yang0_opt(xc, YB_PARENT, NULL, xerr)) < 0)
|
||||
goto done;
|
||||
#else
|
||||
if ((ret = xml_bind_yang0(xc, YB_PARENT, NULL, xerr)) < 0)
|
||||
goto done;
|
||||
#endif
|
||||
if (ret == 0)
|
||||
failed++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,9 +464,7 @@ xml2ns(cxobj *x,
|
|||
* If not, this is devastating when populating deep yang structures
|
||||
*/
|
||||
if (ns &&
|
||||
#ifdef OPTIMIZE_45_BIND /* Dont set cache if few children: if 1 child typically a body */
|
||||
xml_child_nr(x) > 1 &&
|
||||
#endif
|
||||
xml_child_nr(x) > 1 && /* Dont set cache if few children: if 1 child typically a body */
|
||||
nscache_set(x, prefix, ns) < 0)
|
||||
goto done;
|
||||
ok:
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ xml_cv_cache(cxobj *x,
|
|||
return retval;
|
||||
}
|
||||
|
||||
#ifdef OPTIMIZE_45_SORT
|
||||
static int
|
||||
xml_cv_cache_clear(cxobj *xt)
|
||||
{
|
||||
|
|
@ -157,7 +156,6 @@ xml_cv_cache_clear(cxobj *xt)
|
|||
done:
|
||||
return retval;
|
||||
}
|
||||
#endif /* OPTIMIZE_45_SORT */
|
||||
|
||||
/*! Help function to qsort for sorting entries in xml child vector same parent
|
||||
* @param[in] x1 object 1
|
||||
|
|
@ -433,7 +431,6 @@ xml_sort_recurse(cxobj *xn)
|
|||
cxobj *x;
|
||||
int ret;
|
||||
|
||||
#ifdef OPTIMIZE_45_SORT
|
||||
ret = xml_sort_verify(xn, NULL);
|
||||
if (ret == 1) /* This node is not sortable */
|
||||
goto ok;
|
||||
|
|
@ -445,12 +442,6 @@ xml_sort_recurse(cxobj *xn)
|
|||
}
|
||||
if (xml_cv_cache_clear(xn) < 0)
|
||||
goto done;
|
||||
#else
|
||||
if ((ret = xml_sort(xn)) < 0)
|
||||
goto done;
|
||||
if (ret == 1) /* This node is not sortable */
|
||||
goto ok;
|
||||
#endif
|
||||
x = NULL;
|
||||
while ((x = xml_child_each(xn, x, CX_ELMNT)) != NULL) {
|
||||
if (xml_sort_recurse(x) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue