XS.xs

filter: Statementstmt 0.0% 0 / 180 Branchbran 0.0% 0 / 156 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 336 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Mojo/Collection/XS.pm ↑ Summary blib/lib/Mojo/Collection/_Deparsed_XSubs.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #ifndef CVf_HAS_SIGNATURES
6 # define CVf_HAS_SIGNATURES 0
7 #endif
8  
9 MODULE = Mojo::Collection::XS PACKAGE = Mojo::Collection::XS
10  
11 SV *
12 while_fast(self, cb)
13 SV *self
14 SV *cb
15 CODE:
16 {
17 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
18 0 croak("while_fast: self is not an arrayref");
19 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
20 0 croak("while_fast: callback must be a CODE ref");
21  
22 0 AV *av = (AV *)SvRV(self);
23 0 SSize_t max = AvFILL(av);
24  
25 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
26 0 dSP;
27  
28 0 CV *cv = (CV *)SvRV(cb); /* hoisted */
29 0 SV **items = AvARRAY(av);
30  
31 0 ENTER;
32 0 SAVETMPS;
33 0 SAVE_DEFSV; /* alias $_ */
34  
35 0 SV *idx_sv = sv_newmortal();
36  
37 0 ▶ for (SSize_t i = 0, num = 1; i <= max; i++, num++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t i = 0, num = 1; i <= max; i++, num++) { 0 0 0
38 0 SV *e = items[i];
39 0 ▶ if (!e) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!e) continue; 0 0 0
40  
41 0 ▶ DEFSV = e; /* $_ alias */
Branch: 1 branch
BranchTrueFalseTotal
DEFSV = e; /* $_ alias */ 0 0 0
42 0 sv_setiv(idx_sv, num);
43  
44 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
45 0 ▶ XPUSHs(e);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(e); 0 0 0
46 0 ▶ XPUSHs(idx_sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(idx_sv); 0 0 0
47 0 PUTBACK;
48  
49 0 call_sv((SV *)cv, G_VOID | G_DISCARD);
50 0 SPAGAIN;
51 }
52  
53 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
54 0 LEAVE;
55 }
56  
57 0 RETVAL = SvREFCNT_inc(self);
58 }
59 OUTPUT: RETVAL
60  
61 SV *
62 while_ultra(self, cb)
63 SV *self
64 SV *cb
65 CODE:
66 {
67 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
68 0 croak("while_ultra: self is not an arrayref");
69 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
70 0 croak("while_ultra: callback must be a CODE ref");
71  
72 0 AV *av = (AV *)SvRV(self);
73 0 SSize_t max = AvFILL(av);
74  
75 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
76 0 dSP;
77  
78 0 CV *cv = (CV *)SvRV(cb); /* hoist */
79 0 SV **items = AvARRAY(av);
80  
81 0 ENTER;
82 0 SAVETMPS;
83  
84 0 SV *idx_sv = sv_newmortal();
85  
86 0 ▶ for (SSize_t i = 0, num = 1; i <= max; i++, num++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t i = 0, num = 1; i <= max; i++, num++) { 0 0 0
87 0 SV *e = items[i];
88 0 ▶ if (!e) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!e) continue; 0 0 0
89  
90 0 sv_setiv(idx_sv, num);
91  
92 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
93 0 ▶ XPUSHs(e);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(e); 0 0 0
94 0 ▶ XPUSHs(idx_sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(idx_sv); 0 0 0
95 0 PUTBACK;
96  
97 0 call_sv((SV *)cv, G_VOID | G_DISCARD);
98 0 SPAGAIN;
99 }
100  
101 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
102 0 LEAVE;
103 }
104  
105 0 RETVAL = SvREFCNT_inc(self);
106 }
107 OUTPUT: RETVAL
108  
109 SV *
110 each_fast(self, cb)
111 SV *self
112 SV *cb
113 CODE:
114 {
115 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
116 0 croak("Mojo::Collection::XS->each_fast: self is not an arrayref");
117 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
118 0 croak("Mojo::Collection::XS->each_fast: callback must be a CODE ref");
119  
120 0 AV *av = (AV *)SvRV(self);
121 0 SSize_t max = AvFILL(av);
122  
123 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
124 0 dSP;
125  
126 0 CV *cv = (CV *)SvRV(cb); /* hoist sekali */
127 0 SV **items = AvARRAY(av);
128  
129 0 ENTER;
130 0 SAVETMPS;
131 0 SAVE_DEFSV;
132  
133 0 SV *num_sv = sv_2mortal(newSViv(0)); /* reusable index SV */
134  
135 0 ▶ for (SSize_t idx = 0, num = 1; idx <= max; idx++, num++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t idx = 0, num = 1; idx <= max; idx++, num++) { 0 0 0
136 0 SV *item = items[idx];
137 0 ▶ if (!item) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!item) continue; 0 0 0
138  
139 0 ▶ DEFSV = item; /* alias to element */
Branch: 1 branch
BranchTrueFalseTotal
DEFSV = item; /* alias to element */ 0 0 0
140 0 sv_setiv(num_sv, num);
141  
142 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
143 0 ▶ XPUSHs(item);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(item); 0 0 0
144 0 ▶ XPUSHs(num_sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(num_sv); 0 0 0
145 0 PUTBACK;
146  
147 0 call_sv((SV *)cv, G_VOID | G_DISCARD);
148 0 SPAGAIN;
149 }
150  
151 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
152 0 LEAVE;
153 }
154  
155 0 RETVAL = SvREFCNT_inc(self);
156 }
157 OUTPUT:
158 RETVAL
159  
160 SV *
161 map_ultra(self, cb)
162 SV *self
163 SV *cb
164 CODE:
165 {
166 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
167 0 croak("map_ultra: self is not an arrayref");
168 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
169 0 croak("map_ultra: callback must be a CODE ref");
170  
171 0 AV *av = (AV *)SvRV(self);
172 0 SSize_t max = AvFILL(av);
173  
174 0 AV *out = newAV();
175 0 SV *out_rv = newRV_noinc((SV *)out);
176 0 sv_bless(out_rv, SvSTASH(SvRV(self)));
177  
178 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
179 0 dSP;
180  
181 0 CV *cv = (CV *)SvRV(cb);
182 0 SV **items = AvARRAY(av);
183  
184 0 ENTER;
185 0 SAVETMPS;
186 0 av_extend(out, max);
187  
188 0 ▶ for (SSize_t i = 0; i <= max; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t i = 0; i <= max; i++) { 0 0 0
189 0 SV *item = items[i];
190 0 ▶ if (!item) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!item) continue; 0 0 0
191  
192 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
193 0 ▶ XPUSHs(item);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(item); 0 0 0
194 0 PUTBACK;
195  
196 0 I32 count = call_sv((SV *)cv, G_SCALAR);
197 0 SPAGAIN;
198  
199 0 ▶ if (count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 0) { 0 0 0
200 0 SV *ret = POPs;
201 0 ▶ if (ret && ret != &PL_sv_undef) {
Branch: 2 branches
BranchTrueFalseTotal
if (ret && ret != &PL_sv_undef) { 0 0 0
if (ret && ret != &PL_sv_undef) { 0 0 0
202 0 ▶ av_push(out, SvTEMP(ret) ? newSVsv(ret) : SvREFCNT_inc(ret));
Branch: 1 branch
BranchTrueFalseTotal
av_push(out, SvTEMP(ret) ? newSVsv(ret) : SvREFCNT_inc(ret)); 0 0 0
203 }
204 0 ▶ if (count > 1) SP -= (count - 1);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 1) SP -= (count - 1); 0 0 0
205 }
206 }
207  
208 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
209 0 LEAVE;
210 }
211  
212 0 RETVAL = out_rv;
213 }
214 OUTPUT:
215 RETVAL
216  
217 SV *
218 map_fast(self, cb)
219 SV *self
220 SV *cb
221 CODE:
222 {
223 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
224 0 croak("Mojo::Collection::XS->map_fast: self is not an arrayref");
225 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
226 0 croak("Mojo::Collection::XS->map_fast: callback must be a CODE ref");
227  
228 0 AV *av = (AV *)SvRV(self);
229 0 SSize_t max = AvFILL(av);
230  
231 0 AV *out_av = newAV();
232 0 SV *ret_rv = newRV_noinc((SV *)out_av);
233 0 sv_bless(ret_rv, SvSTASH(SvRV(self)));
234  
235 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
236 0 dSP;
237  
238 0 CV *cv = (CV *)SvRV(cb); /* hoist sekali */
239 0 SV **items = AvARRAY(av);
240  
241 0 ENTER;
242 0 SAVETMPS;
243 0 SAVE_DEFSV;
244 0 av_extend(out_av, max);
245  
246 0 ▶ for (SSize_t idx = 0; idx <= max; idx++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t idx = 0; idx <= max; idx++) { 0 0 0
247 0 SV *item = items[idx];
248 0 ▶ if (!item) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!item) continue; 0 0 0
249  
250 0 ▶ DEFSV = item; /* alias to element */
Branch: 1 branch
BranchTrueFalseTotal
DEFSV = item; /* alias to element */ 0 0 0
251  
252 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
253 0 ▶ XPUSHs(item);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(item); 0 0 0
254 0 PUTBACK;
255  
256 0 I32 count = call_sv((SV *)cv, G_ARRAY);
257 0 SPAGAIN;
258  
259 0 ▶ if (count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 0) { 0 0 0
260 0 SV **results = SP - count + 1; /* start of returned values */
261 0 ▶ for (I32 i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (I32 i = 0; i < count; i++) { 0 0 0
262 0 av_push(out_av, newSVsv(results[i]));
263 }
264 0 SP -= count;
265 }
266 }
267  
268 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
269 0 LEAVE;
270 }
271  
272 0 RETVAL = ret_rv;
273 }
274 OUTPUT:
275 RETVAL
276  
277 SV *
278 grep_fast(self, cb)
279 SV *self
280 SV *cb
281 CODE:
282 {
283 0 ▶ if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
if (!SvROK(self) || SvTYPE(SvRV(self)) != SVt_PVAV) 0 0 0
284 0 croak("Mojo::Collection::XS->grep_fast: self is not an arrayref");
285 0 ▶ if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV) 0 0 0
286 0 croak("Mojo::Collection::XS->grep_fast: callback must be a CODE ref");
287  
288 0 AV *av = (AV *)SvRV(self);
289 0 SSize_t max = AvFILL(av);
290  
291 0 AV *out_av = newAV();
292 0 SV *ret_rv = newRV_noinc((SV *)out_av);
293 0 sv_bless(ret_rv, SvSTASH(SvRV(self)));
294  
295 0 ▶ if (max >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (max >= 0) { 0 0 0
296 0 dSP;
297  
298 0 CV *cv = (CV *)SvRV(cb);
299 0 SV **items = AvARRAY(av);
300  
301 0 ENTER;
302 0 SAVETMPS;
303 0 SAVE_DEFSV; /* karena kita set $_ */
304  
305 0 ▶ for (SSize_t idx = 0; idx <= max; idx++) {
Branch: 1 branch
BranchTrueFalseTotal
for (SSize_t idx = 0; idx <= max; idx++) { 0 0 0
306 0 SV *item = items[idx];
307 0 ▶ if (!item) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!item) continue; 0 0 0
308  
309 0 ▶ DEFSV = item; /* $_ = item */
Branch: 1 branch
BranchTrueFalseTotal
DEFSV = item; /* $_ = item */ 0 0 0
310  
311 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
312 0 ▶ XPUSHs(item);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(item); 0 0 0
313 0 PUTBACK;
314  
315 0 I32 count = call_sv((SV *)cv, G_SCALAR);
316 0 SPAGAIN;
317  
318 0 ▶ SV *decision = count > 0 ? POPs : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
SV *decision = count > 0 ? POPs : &PL_sv_undef; 0 0 0
319 0 ▶ if (count > 1) SP -= (count - 1);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 1) SP -= (count - 1); 0 0 0
320  
321 0 ▶ if (decision && SvTRUE(decision)) {
Branch: 2 branches
BranchTrueFalseTotal
if (decision && SvTRUE(decision)) { 0 0 0
if (decision && SvTRUE(decision)) { 0 0 0
322 /* tidak clone: persis referensi aslinya */
323 0 av_push(out_av, SvREFCNT_inc(item));
324 }
325 }
326  
327 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
328 0 LEAVE;
329 }
330  
331 0 RETVAL = ret_rv;
332 }
333 OUTPUT:
334 RETVAL
« blib/lib/Mojo/Collection/XS.pm ↑ Summary blib/lib/Mojo/Collection/_Deparsed_XSubs.pm »