xs/vector.xs

filter: Statementstmt 98.4% 189 / 192 Branchbran 95.6% 133 / 138 (1 uncoverable) Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 97.2% 322 / 330 (1 uncoverable) CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/hamt/hamt_abi_impl.h ↑ Summary include/hamt/hamt_check.h »
1 # HAMT::Vector. Every method that "changes" a vector gives the change a
2 # struct of its own that starts out sharing the receiver's nodes, so the
3 # first thing it touches is copied and the receiver never moves.
4  
5 MODULE = HAMT PACKAGE = HAMT::Vector
6  
7 void
8 new(klass, ...)
9 SV *klass
10 PREINIT:
11 hamt_vec *v;
12 SV *obj;
13 I32 i;
14 CODE:
15 3203 obj = hamt_vec_handle_new(aTHX_ hamt_class_stash(aTHX_ klass), NULL, &v,
16 "HAMT::Vector::new");
17 362663 ▶ for (i = 1; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < items; i++) 359504 3159 362663
18 359504 hamt_xs_vec_push(aTHX_ v, ST(i), "HAMT::Vector::new");
19 3159 ST(0) = obj;
20 3159 XSRETURN(1);
21  
22 void
23 push(self, ...)
24 SV *self
25 PREINIT:
26 hamt_vec *v, *n;
27 SV *obj;
28 I32 i;
29 CODE:
30 96757 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::push");
31 96751 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 2 96749 96751
32 2 hamt_void_warn(aTHX_ "HAMT::Vector::push");
33 2 XSRETURN_EMPTY;
34 }
35 96749 ▶ if (items == 1) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (items == 1) XSRETURN(1); 1 96748 96749
36 96748 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), v, &n, "HAMT::Vector::push");
37 189556 ▶ for (i = 1; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < items; i++) 95941 93615 189556
38 95941 hamt_xs_vec_push(aTHX_ n, ST(i), "HAMT::Vector::push");
39 93615 ST(0) = obj;
40 93615 XSRETURN(1);
41  
42 void
43 set(self, index, value)
44 SV *self
45 SV *index
46 SV *value
47 PREINIT:
48 hamt_vec *v, *n;
49 size_t i;
50 SV *obj;
51 CODE:
52 28513 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::set");
53 28507 ▶ if (!hamt_xs_index(aTHX_ index, v->count, &i))
Branch: 1 branch
BranchTrueFalseTotal
if (!hamt_xs_index(aTHX_ index, v->count, &i)) 6 28501 28507
54 6 croak("HAMT::Vector::set: index %" IVdf " is out of range for %" UVuf " elements",
55 SvIV(index), (UV)v->count);
56 28501 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 1 28500 28501
57 1 hamt_void_warn(aTHX_ "HAMT::Vector::set");
58 1 XSRETURN_EMPTY;
59 }
60 28500 ▶ if (hamt_vec_get(v, i) == (void *)value) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_vec_get(v, i) == (void *)value) XSRETURN(1); 1 28499 28500
61 28499 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), v, &n, "HAMT::Vector::set");
62 27891 hamt_xs_vec_set(aTHX_ n, i, value, "HAMT::Vector::set");
63 25894 ST(0) = obj;
64 25894 XSRETURN(1);
65  
66 void
67 pop(self)
68 SV *self
69 PREINIT:
70 hamt_vec *v, *n;
71 SV *obj;
72 CODE:
73 42140 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::pop");
74 42134 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 2 42132 42134
75 2 hamt_void_warn(aTHX_ "HAMT::Vector::pop");
76 2 XSRETURN_EMPTY;
77 }
78 42132 ▶ if (v->count == 0) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (v->count == 0) XSRETURN(1); 1 42131 42132
79 42131 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), v, &n, "HAMT::Vector::pop");
80 41535 hamt_xs_vec_pop(aTHX_ n, "HAMT::Vector::pop");
81 40902 ST(0) = obj;
82 40902 XSRETURN(1);
83  
84 void
85 get(self, index)
86 SV *self
87 SV *index
88 PREINIT:
89 hamt_vec *v;
90 size_t i;
91 CODE:
92 26383 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::get");
93 26377 ST(0) = hamt_xs_index(aTHX_ index, v->count, &i)
94 26125 ? sv_2mortal(SvREFCNT_inc_simple_NN((SV *)hamt_vec_get(v, i)))
95 26377 ▶ : sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
: sv_newmortal(); 26125 252 26377
96 26377 XSRETURN(1);
97  
98 void
99 first(self)
100 SV *self
101 ALIAS:
102 last = 1
103 PREINIT:
104 hamt_vec *v;
105 CODE:
106 2109 ▶ v = hamt_vec_handle(aTHX_ self, ix ? "HAMT::Vector::last" : "HAMT::Vector::first");
Branch: 1 branch
BranchTrueFalseTotal
v = hamt_vec_handle(aTHX_ self, ix ? "HAMT::Vector::last" : "HAMT::Vector::first"); 1066 1043 2109
107 4194 ST(0) = v->count
108 2095 ▶ ? sv_2mortal(SvREFCNT_inc_simple_NN((SV *)hamt_vec_get(v, ix ? v->count - 1 : 0)))
Branch: 2 branches
BranchTrueFalseTotal
? sv_2mortal(SvREFCNT_inc_simple_NN((SV *)hamt_vec_get(v, ix ? v->count - 1 : 0))) 1059 1036 2095
? sv_2mortal(SvREFCNT_inc_simple_NN((SV *)hamt_vec_get(v, ix ? v->count - 1 : 0))) 1059 1036 2095
109 2097 ▶ : sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
: sv_newmortal(); 2095 2 2097
110 2097 XSRETURN(1);
111  
112 void
113 count(self)
114 SV *self
115 PREINIT:
116 hamt_vec *v;
117 CODE:
118 248765 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::count");
119 248759 ST(0) = sv_2mortal(newSVuv((UV)v->count));
120 248759 XSRETURN(1);
121  
122 # Every value, in order: the stored scalars themselves. In scalar context,
123 # how many.
124 void
125 list(self)
126 SV *self
127 PREINIT:
128 hamt_vec *v;
129 hamt_vec_iter it;
130 void *const *run;
131 size_t start;
132 uint32_t n, i;
133 PPCODE:
134 64535 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::list");
135 64529 ▶ if (GIMME_V == G_VOID) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) XSRETURN_EMPTY; 1 64528 64529
136 64528 ▶ if (GIMME_V == G_SCALAR) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_SCALAR) { 1 64527 64528
137 1 PUSHs(sv_2mortal(newSVuv((UV)v->count)));
138 1 XSRETURN(1);
139 }
140 64527 ▶ # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable branch true 0 64527 64527
141 0 # uncoverable condition left count:1
142 64527 ▶ if (v->count > ((size_t)-1 >> 2))
Branch: 2 branches
BranchTrueFalseTotal
if (v->count > ((size_t)-1 >> 2)) 64527 0 64527
if (v->count > ((size_t)-1 >> 2)) 10 64517 64527
143 64527 croak("HAMT::Vector::list: too many elements for one list"); /* # uncoverable statement */
144 425324 ▶ EXTEND(SP, (SSize_t)v->count);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)v->count); 360797 64527 425324
145 10222227 ▶ hamt_vec_iter_init(&it, v);
Branch: 1 branch
BranchTrueFalseTotal
hamt_vec_iter_init(&it, v); 9861430 360797 10222227
146 9861430 while ((run = hamt_vec_iter_next(&it, &start, &n)))
147 for (i = 0; i < n; i++)
148 PUSHs(sv_2mortal(SvREFCNT_inc_simple_NN((SV *)run[i])));
149  
150 # A new, ordinary array holding a copy of every value.
151 void
152 to_array(self)
153 SV *self
154 PREINIT:
155 hamt_vec *v;
156 hamt_vec_iter it;
157 void *const *run;
158 size_t start;
159 uint32_t n, i;
160 AV *av;
161 CODE:
162 12 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::to_array");
163 6 av = newAV();
164 6 ST(0) = sv_2mortal(newRV_noinc((SV *)av));
165 6 ▶ if (v->count) {
Branch: 1 branch
BranchTrueFalseTotal
if (v->count) { 5 1 6
166 5 ▶ # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable branch true 0 5 5
167 5 # uncoverable condition left count:1
168 if (v->count > (size_t)I32_MAX) croak("HAMT::Vector::to_array: too many elements for an array");
169 6 av_extend(av, (I32)(v->count - 1));
170 110 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 104 6 110
171 3296 ▶ hamt_vec_iter_init(&it, v);
Branch: 1 branch
BranchTrueFalseTotal
hamt_vec_iter_init(&it, v); 3192 104 3296
172 3192 while ((run = hamt_vec_iter_next(&it, &start, &n)))
173 6 for (i = 0; i < n; i++)
174 av_push(av, newSVsv((SV *)run[i]));
175 XSRETURN(1);
176  
177 # Every value of this vector followed by every value of the other.
178 void
179 concat(self, other)
180 SV *self
181 SV *other
182 PREINIT:
183 hamt_vec *v, *o, *n, res;
184 SV *obj;
185 CODE:
186 3371 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::concat");
187 3370 o = hamt_vec_handle(aTHX_ other, "HAMT::Vector::concat");
188 3368 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 1 3367 3368
189 1 hamt_void_warn(aTHX_ "HAMT::Vector::concat");
190 1 XSRETURN_EMPTY;
191 }
192 3367 ▶ if (o->count == 0) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (o->count == 0) XSRETURN(1); 20 3347 3367
193 3347 ▶ if (v->count == 0 && SvSTASH(SvRV(other)) == SvSTASH(SvRV(self))) {
Branch: 2 branches
BranchTrueFalseTotal
if (v->count == 0 && SvSTASH(SvRV(other)) == SvSTASH(SvRV(self))) { 20 3327 3347
if (v->count == 0 && SvSTASH(SvRV(other)) == SvSTASH(SvRV(self))) { 19 1 20
194 19 ST(0) = other;
195 19 XSRETURN(1);
196 }
197 3328 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), NULL, &n, "HAMT::Vector::concat");
198 3324 ▶ if (hamt_vec_concat(HAMT_CX, &res, v, o)) croak("HAMT::Vector::concat: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_vec_concat(HAMT_CX, &res, v, o)) croak("HAMT::Vector::concat: out of memory"); 58 3266 3324
199 3266 *n = res;
200 3266 ST(0) = obj;
201 3266 XSRETURN(1);
202  
203 # The values from one index on, or as many of them as asked for. It clamps:
204 # a length that runs past the end stops at the end, and a start past the end
205 # is an empty vector.
206 void
207 slice(self, from, ...)
208 SV *self
209 SV *from
210 PREINIT:
211 hamt_vec *v, *n, res;
212 IV f, l;
213 size_t start, len;
214 SV *obj;
215 CODE:
216 64657 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::slice");
217 64656 ▶ if (items > 3) croak("HAMT::Vector::slice: too many arguments");
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) croak("HAMT::Vector::slice: too many arguments"); 1 64655 64656
218 64655 f = SvIV(from);
219 64655 ▶ if (f < 0) start = (UV)(-(f + 1)) >= (UV)v->count ? 0 : v->count - (size_t)(-(f + 1)) - 1;
Branch: 2 branches
BranchTrueFalseTotal
if (f < 0) start = (UV)(-(f + 1)) >= (UV)v->count ? 0 : v->count - (size_t)(-(f + 1)) - 1; 4 64651 64655
if (f < 0) start = (UV)(-(f + 1)) >= (UV)v->count ? 0 : v->count - (size_t)(-(f + 1)) - 1; 3 1 4
220 64651 else start = (UV)f > (UV)v->count ? v->count : (size_t)f;
221 64655 len = v->count - start;
222 64655 ▶ if (items == 3 && SvOK(ST(2))) {
Branch: 2 branches
BranchTrueFalseTotal
if (items == 3 && SvOK(ST(2))) { 64649 6 64655
if (items == 3 && SvOK(ST(2))) { 64648 1 64649
223 64648 l = SvIV(ST(2));
224 64648 ▶ if (l < 0) croak("HAMT::Vector::slice: length %" IVdf " is negative", l);
Branch: 1 branch
BranchTrueFalseTotal
if (l < 0) croak("HAMT::Vector::slice: length %" IVdf " is negative", l); 1 64647 64648
225 64647 ▶ if ((UV)l < (UV)len) len = (size_t)l;
Branch: 1 branch
BranchTrueFalseTotal
if ((UV)l < (UV)len) len = (size_t)l; 61719 2928 64647
226 }
227 64654 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 1 64653 64654
228 1 hamt_void_warn(aTHX_ "HAMT::Vector::slice");
229 1 XSRETURN_EMPTY;
230 }
231 64653 ▶ if (len == v->count) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (len == v->count) XSRETURN(1); 167 64486 64653
232 64486 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), NULL, &n, "HAMT::Vector::slice");
233 64478 ▶ if (len) {
Branch: 1 branch
BranchTrueFalseTotal
if (len) { 61919 2559 64478
234 61919 ▶ if (hamt_vec_slice(HAMT_CX, &res, v, start, len)) croak("HAMT::Vector::slice: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_vec_slice(HAMT_CX, &res, v, start, len)) croak("HAMT::Vector::slice: out of memory"); 44 61875 61919
235 61875 *n = res;
236 }
237 64434 ST(0) = obj;
238 64434 XSRETURN(1);
239  
240 # The vector with values put in before an index.
241 void
242 insert(self, index, ...)
243 SV *self
244 SV *index
245 PREINIT:
246 hamt_vec *v, *n, *mid;
247 size_t at;
248 SV *obj;
249 I32 i;
250 CODE:
251 11403 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::insert");
252 11402 ▶ if (!hamt_xs_gap(aTHX_ index, v->count, &at))
Branch: 1 branch
BranchTrueFalseTotal
if (!hamt_xs_gap(aTHX_ index, v->count, &at)) 4 11398 11402
253 4 croak("HAMT::Vector::insert: index %" IVdf " is out of range for %" UVuf " elements",
254 SvIV(index), (UV)v->count);
255 11398 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 1 11397 11398
256 1 hamt_void_warn(aTHX_ "HAMT::Vector::insert");
257 1 XSRETURN_EMPTY;
258 }
259 11397 ▶ if (items == 2) XSRETURN(1);
Branch: 1 branch
BranchTrueFalseTotal
if (items == 2) XSRETURN(1); 1 11396 11397
260 /* The new values go into a vector of their own first, in a handle,
261 * so that one of them dying as it is read leaves nothing behind. */
262 11396 hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), NULL, &mid, "HAMT::Vector::insert");
263 31722 ▶ for (i = 2; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i < items; i++) 20974 10748 31722
264 20974 hamt_xs_vec_push(aTHX_ mid, ST(i), "HAMT::Vector::insert");
265 10748 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::insert");
266 10748 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), NULL, &n, "HAMT::Vector::insert");
267 10428 hamt_xs_vec_splice(aTHX_ n, v, at, 0, mid, "HAMT::Vector::insert");
268 5085 ST(0) = obj;
269 5085 XSRETURN(1);
270  
271 # The vector without the value at an index, or without several from there.
272 void
273 remove(self, index, ...)
274 SV *self
275 SV *index
276 PREINIT:
277 hamt_vec *v, *n;
278 2479 size_t at, len = 1;
279 IV l;
280 SV *obj;
281 CODE:
282 2479 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::remove");
283 2478 ▶ if (items > 3) croak("HAMT::Vector::remove: too many arguments");
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) croak("HAMT::Vector::remove: too many arguments"); 1 2477 2478
284 2477 ▶ if (items == 3 && SvOK(ST(2))) { /* # uncoverable condition right count:2 */
Branch: 2 branches
BranchTrueFalseTotal
if (items == 3 && SvOK(ST(2))) { /* # uncoverable condition right count:2 */ 2468 9 2477
if (items == 3 && SvOK(ST(2))) { /* # uncoverable condition right count:2 */ 2468 0 2468
285 2468 l = SvIV(ST(2));
286 2468 ▶ if (l < 0) croak("HAMT::Vector::remove: length %" IVdf " is negative", l);
Branch: 1 branch
BranchTrueFalseTotal
if (l < 0) croak("HAMT::Vector::remove: length %" IVdf " is negative", l); 1 2467 2468
287 2467 len = (size_t)l;
288 }
289 2476 ▶ if (GIMME_V == G_VOID) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_VOID) { 1 2475 2476
290 1 hamt_void_warn(aTHX_ "HAMT::Vector::remove");
291 1 XSRETURN_EMPTY;
292 }
293 /* An index that names nothing removes nothing. */
294 2475 ▶ if (!hamt_xs_index(aTHX_ index, v->count, &at) || len == 0) XSRETURN(1);
Branch: 2 branches
BranchTrueFalseTotal
if (!hamt_xs_index(aTHX_ index, v->count, &at) || len == 0) XSRETURN(1); 2473 2 2475
if (!hamt_xs_index(aTHX_ index, v->count, &at) || len == 0) XSRETURN(1); 1 2472 2473
295 2472 ▶ if (len > v->count - at) len = v->count - at;
Branch: 1 branch
BranchTrueFalseTotal
if (len > v->count - at) len = v->count - at; 484 1988 2472
296 2472 obj = hamt_vec_handle_new(aTHX_ SvSTASH(SvRV(self)), NULL, &n, "HAMT::Vector::remove");
297 2467 hamt_xs_vec_splice(aTHX_ n, v, at, len, NULL, "HAMT::Vector::remove");
298 2411 ST(0) = obj;
299 2411 XSRETURN(1);
300  
301 # Calls the sub with each value and its index. Returns the vector.
302 void
303 each(self, code)
304 SV *self
305 SV *code
306 PREINIT:
307 hamt_vec *v, *held;
308 hamt_vec_iter it;
309 void *const *run;
310 size_t start;
311 uint32_t n, i;
312 27 SV *idxsv = NULL, *args[2], *err = NULL;
313 27 int how = HAMT_XS_RETURNED;
314 CODE:
315 27 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::each");
316 27 hamt_xs_need_code(aTHX_ code, "HAMT::Vector::each");
317 26 ENTER;
318 26 SAVETMPS;
319 26 held = hamt_xs_hold_vec(aTHX_ v, "HAMT::Vector::each");
320 25 hamt_xs_walk_enter(aTHX);
321 25 hamt_vec_iter_init(&it, held);
322 387 ▶ while (how != HAMT_XS_LAST && !err && (run = hamt_vec_iter_next(&it, &start, &n))) {
Branch: 3 branches
BranchTrueFalseTotal
while (how != HAMT_XS_LAST && !err && (run = hamt_vec_iter_next(&it, &start, &n))) { 381 6 387
while (how != HAMT_XS_LAST && !err && (run = hamt_vec_iter_next(&it, &start, &n))) { 374 7 381
while (how != HAMT_XS_LAST && !err && (run = hamt_vec_iter_next(&it, &start, &n))) { 362 12 374
323 11335 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 10986 349 11335
324 10986 idxsv = hamt_xs_scratch(aTHX_ idxsv);
325 10986 sv_setuv(idxsv, (UV)(start + i));
326 10986 args[0] = (SV *)run[i];
327 10986 args[1] = idxsv;
328 10986 how = hamt_xs_call(aTHX_ code, args, 2, NULL);
329 10986 ▶ if (how == HAMT_XS_LAST || (err = hamt_xs_call_err(aTHX_ how, 1))) break; /* # uncoverable branch true count:1 class:ignore_covered_err */
Branch: 2 branches
BranchTrueFalseTotal
if (how == HAMT_XS_LAST || (err = hamt_xs_call_err(aTHX_ how, 1))) break; /* # uncoverable branch true count:1 class:ignore_covered_err */ 10980 6 10986
if (how == HAMT_XS_LAST || (err = hamt_xs_call_err(aTHX_ how, 1))) break; /* # uncoverable branch true count:1 class:ignore_covered_err */ 10973 7 10980
330 }
331 }
332 25 hamt_xs_call_leave(aTHX);
333 25 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 25 0 25
334 25 LEAVE;
335 25 ▶ if (err) hamt_xs_rethrow(aTHX_ err);
Branch: 1 branch
BranchTrueFalseTotal
if (err) hamt_xs_rethrow(aTHX_ err); 7 18 25
336 18 XSRETURN(1);
337  
338 # True when the other thing is a vector of equal values in the same order.
339 void
340 equals(self, other, ...)
341 SV *self
342 SV *other
343 PREINIT:
344 hamt_vec *v, *o, *ha, *hb;
345 hamt_eq_ctx c;
346 int rc;
347 CODE:
348 42 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::equals");
349 42 ▶ if (items > 3) croak("HAMT::Vector::equals: too many arguments");
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) croak("HAMT::Vector::equals: too many arguments"); 1 41 42
350 41 ▶ if (items == 3) hamt_xs_need_code(aTHX_ ST(2), "HAMT::Vector::equals");
Branch: 1 branch
BranchTrueFalseTotal
if (items == 3) hamt_xs_need_code(aTHX_ ST(2), "HAMT::Vector::equals"); 12 29 41
351 40 o = hamt_vec_handle_try(aTHX_ other);
352 40 ▶ if (!o || o->count != v->count) XSRETURN_NO;
Branch: 2 branches
BranchTrueFalseTotal
if (!o || o->count != v->count) XSRETURN_NO; 37 3 40
if (!o || o->count != v->count) XSRETURN_NO; 2 35 37
353 35 c.cx = HAMT_CX;
354 35 ▶ c.eq = items == 3 ? hamt_xs_eq_cb : NULL;
Branch: 1 branch
BranchTrueFalseTotal
c.eq = items == 3 ? hamt_xs_eq_cb : NULL; 11 24 35
355 35 ▶ c.ud = items == 3 ? (void *)ST(2) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
c.ud = items == 3 ? (void *)ST(2) : NULL; 11 24 35
356 35 c.visits = 0;
357 35 ENTER;
358 35 ha = hamt_xs_hold_vec(aTHX_ v, "HAMT::Vector::equals");
359 34 hb = hamt_xs_hold_vec(aTHX_ o, "HAMT::Vector::equals");
360 33 rc = hamt_vec_equal(&c, ha, hb);
361 25 LEAVE;
362 25 ▶ ST(0) = boolSV(rc > 0);
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = boolSV(rc > 0); 17 8 25
363 25 XSRETURN(1);
364  
365 void
366 transient(self)
367 SV *self
368 PREINIT:
369 hamt_vec *v;
370 hamt_vtxn *t;
371 SV *inner, *rv;
372 MAGIC *mg;
373 CODE:
374 327 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::transient");
375 321 t = (hamt_vtxn *)HAMT_ALLOC(HAMT_CX, sizeof(hamt_vtxn));
376 321 ▶ if (!t) croak("HAMT::Vector::transient: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!t) croak("HAMT::Vector::transient: out of memory"); 2 319 321
377 319 hamt_vec_share(&t->v, v);
378 319 t->origin = (HV *)SvREFCNT_inc_simple_NN((SV *)SvSTASH(SvRV(self)));
379 319 t->open = 1;
380 319 inner = newSV(0);
381 319 mg = sv_magicext(inner, NULL, PERL_MAGIC_ext, &hamt_vec_txn_vtbl, (const char *)t, 0);
382 319 mg->mg_flags |= MGf_DUP;
383 319 rv = sv_2mortal(newRV_noinc(inner));
384 319 sv_bless(rv, gv_stashpvs("HAMT::Vector::Transient", GV_ADD));
385 319 ST(0) = rv;
386 319 XSRETURN(1);
387  
388 void
389 _check(self)
390 SV *self
391 PREINIT:
392 hamt_vec *v;
393 CODE:
394 81260 v = hamt_vec_handle(aTHX_ self, "HAMT::Vector::_check");
395 81254 ST(0) = sv_2mortal(newSViv((IV)hamt_vec_check(v)));
396 81254 XSRETURN(1);
397  
398 void
399 CLONE_SKIP(...)
400 CODE:
401 0 ST(0) = &PL_sv_yes;
402 0 XSRETURN(1);
« include/hamt/hamt_abi_impl.h ↑ Summary include/hamt/hamt_check.h »