xs/vector.xs

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