"How does it compare speed-wise ..."

A very quick benchmark shows no appreciable difference.

#!/usr/bin/env perl use strict; use warnings; use Array::Contains; use List::Util 'any'; use Benchmark 'cmpthese'; my @base = 'A' .. 'Z'; my @search = map +($_, lc), @base; print "\@base[@base]\n"; print "\@search[@search]\n"; cmpthese 0 => { lua => \&lua, acc => \&acc, }; sub lua { for my $x (@search) { my $bool = any { $_ eq $x } @base; } return; } sub acc { for my $x (@search) { my $bool = contains($x, \@base); } return; }

The check on the arrays was the same on each run:

@base[A B C ... X Y Z] @search[A a B b C c ... X x Y y Z z]

Here's the results of three runs:

Rate lua acc lua 15544/s -- -1% acc 15622/s 1% -- Rate acc lua acc 15777/s -- -1% lua 15905/s 1% -- Rate acc lua acc 15782/s -- -0% lua 15857/s 0% --

— Ken


In reply to Re^4: Where does the spurious error message come from? by kcott
in thread Where does the spurious error message come from? by kikuchiyo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.