<commit_before># $Id$

=head1 TITLE

Data::Replace - data replacing implemented in PIR

=head1 SYNOPSIS

    ...

    load_bytecode "library/Data/Replace.pir"

    .local pmc replace

    replace = find_global "Data::Replace", "replace"

    replace( array, old, new )

    ...


=head1 DESCRIPTION

Replaces every occurrence of a specified PMC with another PMC
in a nested, possible self-referential data structure.

=head1 FUNCTIONS

This library provides the following function:

=over 4

=cut

.namespace ["Data::Replace"]

=item replace( where, old, new )

Replaces every "old" with "new" inside the aggregate "where".

=cut

.sub replace
    .param pmc where
    .param pmc oldVal
    .param pmc newVal
    .local pmc cache
    
    new cache, .PerlArray
    __do_replace( where, oldVal, newVal, cache )
.end


.sub __in_cache
    .param pmc val
    .param pmc cache
    .local int i
    .local pmc temp<commit_msg>Get rid of last PerlArray in runtime/parrot/libraries.<commit_after># $Id$

=head1 TITLE

Data::Replace - data replacing implemented in PIR

=head1 SYNOPSIS

    ...

    load_bytecode "library/Data/Replace.pir"

    .local pmc replace

    replace = find_global "Data::Replace", "replace"

    replace( array, old, new )

    ...


=head1 DESCRIPTION

Replaces every occurrence of a specified PMC with another PMC
in a nested, possible self-referential data structure.

=head1 FUNCTIONS

This library provides the following function:

=over 4

=cut

.namespace ["Data::Replace"]

=item replace( where, old, new )

Replaces every "old" with "new" inside the aggregate "where".

=cut

.sub replace
    .param pmc where
    .param pmc oldVal
    .param pmc newVal
    .local pmc cache
    
    new cache, .ResizablePMCArray
    __do_replace( where, oldVal, newVal, cache )
.end


.sub __in_cache
    .param pmc val
    .param pmc cache
    .local int i
    .local pmc temp
{'fraction_non_alphanumeric': 0.08725542041248018, 'fraction_numerical': 0.005288207297726071, 'mean_word_length': 2.9581589958158996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '512285', 'n_tokens_mistral': 645, 'n_tokens_neox': 609, 'n_words': 223}