| 1 |
|
| # HAMT::Set::Transient: a set opened for a batch of updates. |
| 2 |
|
| |
| 3 |
|
| MODULE = HAMT PACKAGE = HAMT::Set::Transient |
| 4 |
|
| |
| 5 |
|
| void |
| 6 |
|
| add(self, ...) |
| 7 |
|
| SV *self |
| 8 |
|
| PREINIT: |
| 9 |
|
| hamt_txn *t; |
| 10 |
|
| I32 i; |
| 11 |
|
| CODE: |
| 12 |
2008 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::add"); |
| 13 |
4015 |
▶ | for (i = 1; i < items; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) { |
2008 |
2007 |
4015 |
|
| 14 |
2008 |
| hamt_xs_put(aTHX_ &t->m, ST(i), NULL, "HAMT::Set::Transient::add"); |
| 15 |
|
| /* Reading a member can run Perl, and Perl can close the transient. */ |
| 16 |
2008 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::add"); |
| 17 |
|
| } |
| 18 |
2007 |
| XSRETURN(1); |
| 19 |
|
| |
| 20 |
|
| void |
| 21 |
|
| remove(self, ...) |
| 22 |
|
| SV *self |
| 23 |
|
| PREINIT: |
| 24 |
|
| hamt_txn *t; |
| 25 |
|
| I32 i; |
| 26 |
|
| CODE: |
| 27 |
1004 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::remove"); |
| 28 |
2008 |
▶ | for (i = 1; i < items; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) { |
1005 |
1003 |
2008 |
|
| 29 |
1005 |
| hamt_xs_del(aTHX_ &t->m, ST(i), "HAMT::Set::Transient::remove"); |
| 30 |
1005 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::remove"); |
| 31 |
|
| } |
| 32 |
1003 |
| XSRETURN(1); |
| 33 |
|
| |
| 34 |
|
| void |
| 35 |
|
| has(self, member) |
| 36 |
|
| SV *self |
| 37 |
|
| SV *member |
| 38 |
|
| PREINIT: |
| 39 |
|
| hamt_txn *t; |
| 40 |
|
| hamt_key k; |
| 41 |
|
| CODE: |
| 42 |
7 |
| hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::has"); |
| 43 |
6 |
| hamt_key_from_sv(aTHX_ member, &k); |
| 44 |
6 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::has"); |
| 45 |
6 |
▶ | ST(0) = boolSV(hamt_map_find(t->m.root, k.p, (size_t)k.len, k.utf8, k.hash) != NULL); |
Branch: 1 branch
| Branch | True | False | Total |
| ST(0) = boolSV(hamt_map_find(t->m.root, k.p, (size_t)k.len, k.utf8, k.hash) != NULL); |
3 |
3 |
6 |
|
| 46 |
6 |
| XSRETURN(1); |
| 47 |
|
| |
| 48 |
|
| void |
| 49 |
|
| count(self) |
| 50 |
|
| SV *self |
| 51 |
|
| PREINIT: |
| 52 |
|
| hamt_txn *t; |
| 53 |
|
| CODE: |
| 54 |
5 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::count"); |
| 55 |
4 |
| ST(0) = sv_2mortal(newSVuv((UV)t->m.count)); |
| 56 |
4 |
| XSRETURN(1); |
| 57 |
|
| |
| 58 |
|
| void |
| 59 |
|
| persistent(self) |
| 60 |
|
| SV *self |
| 61 |
|
| PREINIT: |
| 62 |
|
| hamt_txn *t; |
| 63 |
|
| hamt_map *n; |
| 64 |
|
| hamt_node *root; |
| 65 |
|
| HV *origin; |
| 66 |
|
| SV *obj; |
| 67 |
|
| CODE: |
| 68 |
4 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::persistent"); |
| 69 |
3 |
| obj = hamt_handle_new(aTHX_ &hamt_set_vtbl, t->origin, t->m.root, t->m.count, |
| 70 |
|
| &n, "HAMT::Set::Transient::persistent"); |
| 71 |
3 |
| root = t->m.root; |
| 72 |
3 |
| origin = t->origin; |
| 73 |
3 |
| t->open = 0; |
| 74 |
3 |
| t->m.root = NULL; |
| 75 |
3 |
| t->m.count = 0; |
| 76 |
3 |
| t->origin = NULL; |
| 77 |
3 |
| SvREFCNT_dec((SV *)origin); |
| 78 |
3 |
▶ | if (root) hamt_node_release(HAMT_CX, root); |
Branch: 1 branch
| Branch | True | False | Total |
| if (root) hamt_node_release(HAMT_CX, root); |
3 |
0 |
3 |
|
| 79 |
3 |
| ST(0) = obj; |
| 80 |
3 |
| XSRETURN(1); |
| 81 |
|
| |
| 82 |
|
| void |
| 83 |
|
| _check(self) |
| 84 |
|
| SV *self |
| 85 |
|
| PREINIT: |
| 86 |
|
| hamt_txn *t; |
| 87 |
|
| CODE: |
| 88 |
1 |
| t = hamt_txn_handle(aTHX_ self, &hamt_set_txn_vtbl, "HAMT::Set::Transient::_check"); |
| 89 |
1 |
| ST(0) = sv_2mortal(newSViv((IV)hamt_map_check(t->m.root, t->m.count))); |
| 90 |
1 |
| XSRETURN(1); |
| 91 |
|
| |
| 92 |
|
| void |
| 93 |
|
| CLONE_SKIP(...) |
| 94 |
|
| CODE: |
| 95 |
0 |
| ST(0) = &PL_sv_yes; |
| 96 |
0 |
| XSRETURN(1); |