Benchmark-Perl-Formance-Cargo

 view release on metacpan or  search on metacpan

share/PerlCritic/Critic/Document.pm  view on Meta::CPAN


    use PPI::Document;
    use Perl::Critic::Document;
    my $doc = PPI::Document->new('Foo.pm');
    $doc = Perl::Critic::Document->new(-source => $doc);
    ## Then use the instance just like a PPI::Document


=head1 DESCRIPTION

Perl::Critic does a lot of iterations over the PPI document tree via
the C<PPI::Document::find()> method.  To save some time, this class
pre-caches a lot of the common C<find()> calls in a single traversal.
Then, on subsequent requests we return the cached data.

This is implemented as a facade, where method calls are handed to the
stored C<PPI::Document> instance.


=head1 CAVEATS

share/SpamAssassin/easy_ham_2/00295.37087d1f5c2678b8152b397111456d3f  view on Meta::CPAN

> > };
> 
> Unfortunately strlen is a relatively expensive operation. If you are using
> C++ this is not such a big issue as string.length() can be declared const.
> So long as you do not modify the string object, the compiler can do the
> caching for you.

There's a more simple reason as to why strlen shouldn't be used on
the string here, and that's because in future you could actually
change the contents of ``somestring'' within the for loop, and be
left wondering why the number of iterations are not as you expect.

Phil.

-- 
Irish Linux Users' Group: ilug@linux.ie
http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
List maintainer: listmaster@linux.ie




( run in 1.465 second using v1.01-cache-2.11-cpan-96521ef73a4 )