<commit_before>my class SetHash does Setty {

    method ISINSET(\key) {
        Proxy.new(
          FETCH => { %!elems.EXISTS-KEY(key) },
          STORE => -> $, \value {
              %!elems.DELETE-KEY(key) unless value;
              value;
          }
        );
    }

    multi method kv(SetHash:D:) {
        %!elems.kv.map: -> \k,\v { |(v,self.ISINSET(k)) }
    }
    multi method values(SetHash:D:) {
        %!elems.keys.map: -> \key { self.ISINSET(key) }
    }
    multi method pairs(SetHash:D:) {
        %!elems.kv.map: -> \k,\v --> Pair { Pair.new(v,self.ISINSET(k)) }
    }
    multi method antipairs(SetHash:D:) {
        %!elems.values.map: -> \key --> Pair { Pair.new(True,key) }
    }

    method Set(SetHash:D: :$view) {
        $view
          ?? nqp::p6bindattrinvres(nqp::create(Set),Set,'%!elems',%!elems)
          !! Set.new(self.keys)
    }
    method SetHash(SetHash:D:) { self }

    multi method AT-KEY(SetHash:D: \k --> Bool) is raw {
        Proxy.new(
          FETCH => {
              %!elems.EXISTS-KEY(k.WHICH);
          },
          STORE => -> $, $value {
              $value
                ?? %!elems.ASSIGN-KEY(k.WHICH,k)
                !! %!elems.DELETE-KEY(k.WHICH);
              so $value;
          });
    }
    multi method DELETE-KEY(SetHash:D: \k --> Bool) {
        nqp::if(
          %!elems.EXISTS-KEY(my $key := k.WHICH),
          nqp::stmts(
            %!elems.DELETE-KEY($key),
            True<commit_msg>Make SetHash.Set about 80x faster<commit_after>my class SetHash does Setty {

    method ISINSET(\key) {
        Proxy.new(
          FETCH => { %!elems.EXISTS-KEY(key) },
          STORE => -> $, \value {
              %!elems.DELETE-KEY(key) unless value;
              value;
          }
        );
    }

    multi method kv(SetHash:D:) {
        %!elems.kv.map: -> \k,\v { |(v,self.ISINSET(k)) }
    }
    multi method values(SetHash:D:) {
        %!elems.keys.map: -> \key { self.ISINSET(key) }
    }
    multi method pairs(SetHash:D:) {
        %!elems.kv.map: -> \k,\v --> Pair { Pair.new(v,self.ISINSET(k)) }
    }
    multi method antipairs(SetHash:D:) {
        %!elems.values.map: -> \key --> Pair { Pair.new(True,key) }
    }

    method Set(SetHash:D: :$view) {
        nqp::p6bindattrinvres(
          nqp::create(Set),Set,'%!elems',
          $view ?? %!elems !! %!elems.clone
        )
    }
    method SetHash(SetHash:D:) { self }

    multi method AT-KEY(SetHash:D: \k --> Bool) is raw {
        Proxy.new(
          FETCH => {
              %!elems.EXISTS-KEY(k.WHICH);
          },
          STORE => -> $, $value {
              $value
                ?? %!elems.ASSIGN-KEY(k.WHICH,k)
                !! %!elems.DELETE-KEY(k.WHICH);
              so $value;
          });
    }
    multi method DELETE-KEY(SetHash:D: \k --> Bool) {
        nqp::if(
          %!elems.EXISTS-KEY(my $key := k.WHICH),
          nqp::stmts(
            %!elems.DELETE-KEY($key),
            True
{'fraction_non_alphanumeric': 0.18261455525606468, 'fraction_numerical': 0.0013477088948787063, 'mean_word_length': 1.5594827586206896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6395448', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1074, 'n_words': 165}