diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2011-03-17 11:48:54 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2011-03-17 11:48:54 -0700 |
commit | eb9f5718d412022015bb65eb08c30785c79e79e6 (patch) | |
tree | be0b6a9de27965e39c44c5c8a88adf9caa13abf8 /perl_dmod | |
parent | cda3f423c311fd30e8cc24e2de67d99baf352b2a (diff) | |
download | vyatta-cfg-eb9f5718d412022015bb65eb08c30785c79e79e6.tar.gz vyatta-cfg-eb9f5718d412022015bb65eb08c30785c79e79e6.zip |
add config path abstraction and high-level caching
* part of the config backend cleanup/optimization work.
* improves the performance of "load" (w/o commit) by ~55% and "show" by ~15%.
Diffstat (limited to 'perl_dmod')
-rw-r--r-- | perl_dmod/Cstore/Cstore.xs | 145 | ||||
-rw-r--r-- | perl_dmod/Cstore/typemap | 15 |
2 files changed, 88 insertions, 72 deletions
diff --git a/perl_dmod/Cstore/Cstore.xs b/perl_dmod/Cstore/Cstore.xs index 730a936..e5fd126 100644 --- a/perl_dmod/Cstore/Cstore.xs +++ b/perl_dmod/Cstore/Cstore.xs @@ -31,6 +31,7 @@ using namespace cstore; typedef SV STRVEC; +typedef SV CPATH; typedef SV STRSTRMAP; MODULE = Cstore PACKAGE = Cstore @@ -45,43 +46,43 @@ OUTPUT: bool -Cstore::cfgPathExists(STRVEC *vref, bool active_cfg) +Cstore::cfgPathExists(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathExists(arg_strvec, active_cfg); + RETVAL = THIS->cfgPathExists(arg_cpath, active_cfg); OUTPUT: RETVAL bool -Cstore::cfgPathDefault(STRVEC *vref, bool active_cfg) +Cstore::cfgPathDefault(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathDefault(arg_strvec, active_cfg); + RETVAL = THIS->cfgPathDefault(arg_cpath, active_cfg); OUTPUT: RETVAL STRVEC * -Cstore::cfgPathGetChildNodes(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetChildNodes(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetChildNodes(arg_strvec, ret_strvec, active_cfg); + THIS->cfgPathGetChildNodes(arg_cpath, ret_strvec, active_cfg); OUTPUT: RETVAL SV * -Cstore::cfgPathGetValue(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetValue(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: string value; - if (THIS->cfgPathGetValue(arg_strvec, value, active_cfg)) { + if (THIS->cfgPathGetValue(arg_cpath, value, active_cfg)) { RETVAL = newSVpv(value.c_str(), 0); } else { XSRETURN_UNDEF; @@ -91,44 +92,44 @@ OUTPUT: STRVEC * -Cstore::cfgPathGetValues(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetValues(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetValues(arg_strvec, ret_strvec, active_cfg); + THIS->cfgPathGetValues(arg_cpath, ret_strvec, active_cfg); OUTPUT: RETVAL bool -Cstore::cfgPathEffective(STRVEC *vref) +Cstore::cfgPathEffective(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathEffective(arg_strvec); + RETVAL = THIS->cfgPathEffective(arg_cpath); OUTPUT: RETVAL STRVEC * -Cstore::cfgPathGetEffectiveChildNodes(STRVEC *vref) +Cstore::cfgPathGetEffectiveChildNodes(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetEffectiveChildNodes(arg_strvec, ret_strvec); + THIS->cfgPathGetEffectiveChildNodes(arg_cpath, ret_strvec); OUTPUT: RETVAL SV * -Cstore::cfgPathGetEffectiveValue(STRVEC *vref) +Cstore::cfgPathGetEffectiveValue(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: string value; - if (THIS->cfgPathGetEffectiveValue(arg_strvec, value)) { + if (THIS->cfgPathGetEffectiveValue(arg_cpath, value)) { RETVAL = newSVpv(value.c_str(), 0); } else { XSRETURN_UNDEF; @@ -138,97 +139,97 @@ OUTPUT: STRVEC * -Cstore::cfgPathGetEffectiveValues(STRVEC *vref) +Cstore::cfgPathGetEffectiveValues(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetEffectiveValues(arg_strvec, ret_strvec); + THIS->cfgPathGetEffectiveValues(arg_cpath, ret_strvec); OUTPUT: RETVAL bool -Cstore::cfgPathDeleted(STRVEC *vref) +Cstore::cfgPathDeleted(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathDeleted(arg_strvec); + RETVAL = THIS->cfgPathDeleted(arg_cpath); OUTPUT: RETVAL bool -Cstore::cfgPathAdded(STRVEC *vref) +Cstore::cfgPathAdded(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathAdded(arg_strvec); + RETVAL = THIS->cfgPathAdded(arg_cpath); OUTPUT: RETVAL bool -Cstore::cfgPathChanged(STRVEC *vref) +Cstore::cfgPathChanged(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathChanged(arg_strvec); + RETVAL = THIS->cfgPathChanged(arg_cpath); OUTPUT: RETVAL STRVEC * -Cstore::cfgPathGetDeletedChildNodes(STRVEC *vref) +Cstore::cfgPathGetDeletedChildNodes(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetDeletedChildNodes(arg_strvec, ret_strvec); + THIS->cfgPathGetDeletedChildNodes(arg_cpath, ret_strvec); OUTPUT: RETVAL STRVEC * -Cstore::cfgPathGetDeletedValues(STRVEC *vref) +Cstore::cfgPathGetDeletedValues(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetDeletedValues(arg_strvec, ret_strvec); + THIS->cfgPathGetDeletedValues(arg_cpath, ret_strvec); OUTPUT: RETVAL STRSTRMAP * -Cstore::cfgPathGetChildNodesStatus(STRVEC *vref) +Cstore::cfgPathGetChildNodesStatus(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: Cstore::MapT<string, string> ret_strstrmap; - THIS->cfgPathGetChildNodesStatus(arg_strvec, ret_strstrmap); + THIS->cfgPathGetChildNodesStatus(arg_cpath, ret_strstrmap); OUTPUT: RETVAL STRVEC * -Cstore::cfgPathGetValuesDA(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetValuesDA(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetValuesDA(arg_strvec, ret_strvec, active_cfg); + THIS->cfgPathGetValuesDA(arg_cpath, ret_strvec, active_cfg); OUTPUT: RETVAL SV * -Cstore::cfgPathGetValueDA(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetValueDA(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: string value; - if (THIS->cfgPathGetValueDA(arg_strvec, value, active_cfg)) { + if (THIS->cfgPathGetValueDA(arg_cpath, value, active_cfg)) { RETVAL = newSVpv(value.c_str(), 0); } else { XSRETURN_UNDEF; @@ -238,65 +239,65 @@ OUTPUT: STRVEC * -Cstore::cfgPathGetChildNodesDA(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetChildNodesDA(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->cfgPathGetChildNodesDA(arg_strvec, ret_strvec, active_cfg); + THIS->cfgPathGetChildNodesDA(arg_cpath, ret_strvec, active_cfg); OUTPUT: RETVAL bool -Cstore::cfgPathDeactivated(STRVEC *vref, bool active_cfg) +Cstore::cfgPathDeactivated(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->cfgPathDeactivated(arg_strvec, active_cfg); + RETVAL = THIS->cfgPathDeactivated(arg_cpath, active_cfg); OUTPUT: RETVAL STRSTRMAP * -Cstore::cfgPathGetChildNodesStatusDA(STRVEC *vref) +Cstore::cfgPathGetChildNodesStatusDA(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: Cstore::MapT<string, string> ret_strstrmap; - THIS->cfgPathGetChildNodesStatusDA(arg_strvec, ret_strstrmap); + THIS->cfgPathGetChildNodesStatusDA(arg_cpath, ret_strstrmap); OUTPUT: RETVAL STRVEC * -Cstore::tmplGetChildNodes(STRVEC *vref) +Cstore::tmplGetChildNodes(CPATH *pref) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: vector<string> ret_strvec; - THIS->tmplGetChildNodes(arg_strvec, ret_strvec); + THIS->tmplGetChildNodes(arg_cpath, ret_strvec); OUTPUT: RETVAL bool -Cstore::validateTmplPath(STRVEC *vref, bool validate_vals) +Cstore::validateTmplPath(CPATH *pref, bool validate_vals) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: - RETVAL = THIS->validateTmplPath(arg_strvec, validate_vals); + RETVAL = THIS->validateTmplPath(arg_cpath, validate_vals); OUTPUT: RETVAL STRSTRMAP * -Cstore::getParsedTmpl(STRVEC *vref, bool allow_val) +Cstore::getParsedTmpl(CPATH *pref, bool allow_val) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: Cstore::MapT<string, string> ret_strstrmap; - if (!THIS->getParsedTmpl(arg_strvec, ret_strstrmap, allow_val)) { + if (!THIS->getParsedTmpl(arg_cpath, ret_strstrmap, allow_val)) { XSRETURN_UNDEF; } OUTPUT: @@ -304,12 +305,12 @@ OUTPUT: SV * -Cstore::cfgPathGetComment(STRVEC *vref, bool active_cfg) +Cstore::cfgPathGetComment(CPATH *pref, bool active_cfg) PREINIT: - vector<string> arg_strvec; + Cpath arg_cpath; CODE: string comment; - if (THIS->cfgPathGetComment(arg_strvec, comment, active_cfg)) { + if (THIS->cfgPathGetComment(arg_cpath, comment, active_cfg)) { RETVAL = newSVpv(comment.c_str(), 0); } else { XSRETURN_UNDEF; diff --git a/perl_dmod/Cstore/typemap b/perl_dmod/Cstore/typemap index 6df545b..7f70899 100644 --- a/perl_dmod/Cstore/typemap +++ b/perl_dmod/Cstore/typemap @@ -14,6 +14,7 @@ Cstore * O_CPPOBJ STRVEC * T_STRVEC_REF +CPATH * T_CPATH_REF STRSTRMAP * T_STRSTRMAP_REF @@ -66,3 +67,17 @@ T_STRVEC_REF } } +T_CPATH_REF + { + int i = 0; + I32 num = 0; + if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) { + XSRETURN_UNDEF; + } + num = av_len((AV *) SvRV($arg)); + /* if input array is empty, path will be empty as well. */ + for (i = 0; i <= num; i++) { + arg_cpath.push(SvPV_nolen(*av_fetch((AV *) SvRV($arg), i, 0))); + } + } + |