← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Data/Perl/Collection/Array/MooseLike.pm
StatementsExecuted 11 statements in 654µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111605µs757µsData::Perl::Collection::Array::MooseLike::::BEGIN@7Data::Perl::Collection::Array::MooseLike::BEGIN@7
11143µs163µsData::Perl::Collection::Array::MooseLike::::BEGIN@5Data::Perl::Collection::Array::MooseLike::BEGIN@5
11115µs70µsData::Perl::Collection::Array::MooseLike::::BEGIN@8Data::Perl::Collection::Array::MooseLike::BEGIN@8
0000s0sData::Perl::Collection::Array::MooseLike::::__ANON__[:20]Data::Perl::Collection::Array::MooseLike::__ANON__[:20]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Data::Perl::Collection::Array::MooseLike;
211µs$Data::Perl::Collection::Array::MooseLike::VERSION = '0.001009';
3# ABSTRACT: Collection::Array subclass that simulates Moose's native traits.
4
5349µs3283µs
# spent 163µs (43+120) within Data::Perl::Collection::Array::MooseLike::BEGIN@5 which was called: # once (43µs+120µs) by Module::Runtime::require_module at line 5
use strictures 1;
# spent 163µs making 1 call to Data::Perl::Collection::Array::MooseLike::BEGIN@5 # spent 97µs making 1 call to strictures::import # spent 23µs making 1 call to strictures::VERSION
6
72396µs2797µs
# spent 757µs (605+152) within Data::Perl::Collection::Array::MooseLike::BEGIN@7 which was called: # once (605µs+152µs) by Module::Runtime::require_module at line 7
use Role::Tiny::With;
# spent 757µs making 1 call to Data::Perl::Collection::Array::MooseLike::BEGIN@7 # spent 40µs making 1 call to Exporter::import
82194µs2125µs
# spent 70µs (15+55) within Data::Perl::Collection::Array::MooseLike::BEGIN@8 which was called: # once (15µs+55µs) by Module::Runtime::require_module at line 8
use Class::Method::Modifiers;
# spent 70µs making 1 call to Data::Perl::Collection::Array::MooseLike::BEGIN@8 # spent 55µs making 1 call to Exporter::import
9
1012µs13.68mswith 'Data::Perl::Role::Collection::Array';
# spent 3.68ms making 1 call to Role::Tiny::With::with
11
12around 'splice' => sub {
13 my $orig = shift;
14 my @res = $orig->(@_);
15
16 # support both class instance method invocation style
17 @res = blessed($res[0]) && $res[0]->isa('Data::Perl::Collection::Array') ? $res[0]->flatten : @res;
18
19 wantarray ? @res : $res[-1];
2017µs1158µs};
# spent 158µs making 1 call to Class::Method::Modifiers::around
21
2215µs1;
23
24=pod
25
26=encoding UTF-8
27
28=head1 NAME
29
30Data::Perl::Collection::Array::MooseLike - Collection::Array subclass that simulates Moose's native traits.
31
32=head1 VERSION
33
34version 0.001009
35
36=head1 SYNOPSIS
37
38 use Data::Perl::Collection::Array::MooseLike;
39
40 my $array = Data::Perl::Collection::Array::MooseLike->new(qw/a b c d/);
41
42 my $scalar_context = $array->splice(0, 2); # removes and returns b
43
44 my @list_context = $array->splice(0, 2); # returns and removes (b, c)
45
46=head1 DESCRIPTION
47
48This class provides a wrapper and methods for interacting with an array. All
49methods are written to emulate/match existing behavior that exists with Moose's
50native traits.
51
52=head1 DIFFERENCES IN FUNCTIONALITY
53
54=over 4
55
56=item B<splice($args, ...)>
57
58Just like Perl's builtin splice. In scalar context, this returns the last
59element removed, or undef if no elements were removed. In list context, this
60returns all the elements removed from the array.
61
62This method requires at least one argument.
63
64=back
65
66=head1 SEE ALSO
67
68=over 4
69
70=item * L<Data::Perl>
71
72=item * L<Data::Perl::Role::Collection::Array>
73
74=back
75
76=head1 AUTHOR
77
78Toby Inkster <tobyink@cpan.org>
79
80=head1 COPYRIGHT AND LICENSE
81
82This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>.
83
84This is free software; you can redistribute it and/or modify it under
85the same terms as the Perl 5 programming language system itself.
86
87=cut
88
89__END__