summaryrefslogtreecommitdiffstats
path: root/XS.xs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-12-09 21:52:08 -0600
committerJesse Luehrs <doy@tozt.net>2011-12-09 21:52:39 -0600
commite290a0364d7a77719b5b46c59ad70f5be5b08076 (patch)
treee68e04426c2dd3ac70a15d8456a51679b64fe883 /XS.xs
parent2d533eafbee81a1c51334a351b2e309ace8d3508 (diff)
downloadpackage-stash-xs-e290a0364d7a77719b5b46c59ad70f5be5b08076.tar.gz
package-stash-xs-e290a0364d7a77719b5b46c59ad70f5be5b08076.zip
use gv_init here instead of gv_fetchsv
Diffstat (limited to 'XS.xs')
-rw-r--r--XS.xs30
1 files changed, 21 insertions, 9 deletions
diff --git a/XS.xs b/XS.xs
index 8bb5e84..4fcd6e8 100644
--- a/XS.xs
+++ b/XS.xs
@@ -493,22 +493,19 @@ add_symbol(self, variable, initial=NULL, ...)
varspec_t variable
SV *initial
PREINIT:
- SV *name;
GV *glob;
+ HV *namespace;
+ HE *entry;
CODE:
if (initial && !_valid_for_type(initial, variable.type))
croak("%s is not of type %s",
SvPV_nolen(initial), vartype_to_string(variable.type));
- name = newSVsv(_get_name(self));
- sv_catpvs(name, "::");
- sv_catsv(name, variable.name);
-
if (items > 2 && (PL_perldb & 0x10) && variable.type == VAR_CODE) {
int i;
char *filename = NULL;
I32 first_line_num = -1, last_line_num = -1;
- SV *dbval;
+ SV *dbval, *name;
HV *dbsub;
if ((items - 3) % 2)
@@ -544,6 +541,10 @@ add_symbol(self, variable, initial=NULL, ...)
if (last_line_num == -1)
last_line_num = first_line_num;
+ name = newSVsv(_get_name(self));
+ sv_catpvs(name, "::");
+ sv_catsv(name, variable.name);
+
/* http://perldoc.perl.org/perldebguts.html#Debugger-Internals */
dbsub = get_hv("DB::sub", 1);
dbval = newSVpvf("%s:%d-%d", filename, first_line_num, last_line_num);
@@ -552,12 +553,25 @@ add_symbol(self, variable, initial=NULL, ...)
SvPV_nolen(name));
SvREFCNT_dec(dbval);
}
+
+ SvREFCNT_dec(name);
}
/* GV_ADDMULTI rather than GV_ADD because otherwise you get 'used only
* once' warnings in some situations... i can't reproduce this, but CMOP
* triggers it */
- glob = gv_fetchsv(name, GV_ADDMULTI, vartype_to_svtype(variable.type));
+ namespace = _get_namespace(self);
+ entry = hv_fetch_ent(namespace, variable.name, 0, 0);
+ if (entry) {
+ glob = (GV*)HeVAL(entry);
+ }
+ else {
+ glob = (GV*)newSV(0);
+ gv_init(glob, namespace, "ANON", 4, 1);
+ if (!hv_store_ent(namespace, variable.name, (SV*)glob, 0)) {
+ croak("hv_store failed");
+ }
+ }
if (initial) {
SV *val;
@@ -589,8 +603,6 @@ add_symbol(self, variable, initial=NULL, ...)
}
}
- SvREFCNT_dec(name);
-
void
remove_glob(self, name)
SV *self