xs/vector_transient.xs

filter: Statementstmt 94.5% 35 / 37 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 95.3% 41 / 43 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/set_transient.xs ↑ Summary include/hamt/hamt_abi_impl.h »
1 # HAMT::Vector::Transient: a vector opened for a batch of updates.
2  
3 MODULE = HAMT PACKAGE = HAMT::Vector::Transient
4  
5 void
6 push(self, ...)
7 SV *self
8 PREINIT:
9 hamt_vtxn *t;
10 I32 i;
11 CODE:
12 83238 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::push");
13 166466 ▶ for (i = 1; i < items; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < items; i++) { 83237 83229 166466
14 83237 hamt_xs_vec_push(aTHX_ &t->v, ST(i), "HAMT::Vector::Transient::push");
15 /* Reading a value can run Perl, and Perl can close the transient. */
16 83230 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::push");
17 }
18 83229 XSRETURN(1);
19  
20 void
21 set(self, index, value)
22 SV *self
23 SV *index
24 SV *value
25 PREINIT:
26 hamt_vtxn *t;
27 size_t i;
28 CODE:
29 15065 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::set");
30 15064 ▶ if (!hamt_xs_index(aTHX_ index, t->v.count, &i))
Branch: 1 branch
BranchTrueFalseTotal
if (!hamt_xs_index(aTHX_ index, t->v.count, &i)) 1 15063 15064
31 1 croak("HAMT::Vector::Transient::set: index %" IVdf " is out of range for %" UVuf " elements",
32 SvIV(index), (UV)t->v.count);
33 15063 hamt_xs_vec_set(aTHX_ &t->v, i, value, "HAMT::Vector::Transient::set");
34 15061 XSRETURN(1);
35  
36 void
37 pop(self)
38 SV *self
39 PREINIT:
40 hamt_vtxn *t;
41 CODE:
42 63145 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::pop");
43 63144 hamt_xs_vec_pop(aTHX_ &t->v, "HAMT::Vector::Transient::pop");
44 63144 XSRETURN(1);
45  
46 void
47 get(self, index)
48 SV *self
49 SV *index
50 PREINIT:
51 hamt_vtxn *t;
52 size_t i;
53 CODE:
54 5075 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::get");
55 5074 ST(0) = hamt_xs_index(aTHX_ index, t->v.count, &i)
56 5056 ? sv_2mortal(SvREFCNT_inc_simple_NN((SV *)hamt_vec_get(&t->v, i)))
57 5074 ▶ : sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
: sv_newmortal(); 5056 18 5074
58 5074 XSRETURN(1);
59  
60 void
61 count(self)
62 SV *self
63 PREINIT:
64 hamt_vtxn *t;
65 CODE:
66 100009 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::count");
67 100007 ST(0) = sv_2mortal(newSVuv((UV)t->v.count));
68 100007 XSRETURN(1);
69  
70 # An ordinary vector of what the transient holds, of the class it was opened
71 # from. The transient is closed, and holds nothing afterwards.
72 void
73 persistent(self)
74 SV *self
75 PREINIT:
76 hamt_vtxn *t;
77 hamt_vec *n, gone;
78 HV *origin;
79 SV *obj;
80 CODE:
81 304 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::persistent");
82 303 obj = hamt_vec_handle_new(aTHX_ t->origin, &t->v, &n,
83 "HAMT::Vector::Transient::persistent");
84 301 gone = t->v;
85 301 origin = t->origin;
86 301 t->open = 0;
87 301 t->origin = NULL;
88 301 hamt_vec_init(&t->v);
89 301 SvREFCNT_dec((SV *)origin);
90 301 hamt_vec_clear(HAMT_CX, &gone);
91 301 ST(0) = obj;
92 301 XSRETURN(1);
93  
94 void
95 _check(self)
96 SV *self
97 PREINIT:
98 hamt_vtxn *t;
99 CODE:
100 3 t = hamt_vtxn_handle(aTHX_ self, "HAMT::Vector::Transient::_check");
101 3 ST(0) = sv_2mortal(newSViv((IV)hamt_vec_check(&t->v)));
102 3 XSRETURN(1);
103  
104 void
105 CLONE_SKIP(...)
106 CODE:
107 0 ST(0) = &PL_sv_yes;
108 0 XSRETURN(1);
« xs/set_transient.xs ↑ Summary include/hamt/hamt_abi_impl.h »