It's not that index doesn't use Boyer Moore, it's more that the regex engine doesn't always use Boyer Moore. If the regex engine comes to the conclusion to use screaminstr, it will use that instead of Boyer Moore.

I guess that if you change your data to be more favorable to Boyer Moore, the results will reverse as the regular expression will still not use Boyer Moore.

Update: Even weirder. Looking at the log of use re 'Debug','ALL';, it claims that fbm_instr() is used:

C:\Projekte>perl -Mre=Debug,ALL -e "shift=~/abcdefghijklmnopqrstuvwxyz +X/" abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef ghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzXabcdefghijklmnopqrstuvw +xyzabcdefghijklmnopqrstuvwxyz Compiling REx "abcdefghijklmnopqrstuvwxyzX" Starting first pass (sizing) >abcdefghij... | 1| reg | | brnc | | piec | | atom Required size 9 nodes Starting second pass (creation) >abcdefghij... | 1| reg | | brnc | | piec | | atom >< | 10| tail~ EXACT <abcdefghijklmnopqrstuvwxyzX> (1 +) -> END first:> 1: EXACT <abcdefghijklmnopqrstuvwxyzX> (9) first at 1 Peep:Pos:0/0 Flags: 0x0 Whilem_c: 0 Lcp: 0 Last:'' 0:0/0 *Fixed:'' @ 0 + Float: '' @ 0/0 Peep> 1: EXACT <abcdefghijklmnopqrstuvwxyzX> (9) join> 1: EXACT <abcdefghijklmnopqrstuvwxyzX> (9) pre-fin:Pos:27/0 Flags: 0x0 Whilem_c: 0 Lcp: 0 Last:'abcdefghijklmnopq +rstuvwxyzX' 27:0/0 *Fixed:'' @ 0 Float: '' @ 0/0 post-fin:Pos:27/0 Flags: 0x0 Whilem_c: 0 Lcp: 0 Last:'abcdefghijklmnop +qrstuvwxyzX' 27:0/0 *Fixed:'' @ 0 Float: '' @ 0/0 commit: Pos:27/0 Flags: 0x0 Whilem_c: 0 Lcp: 0 Last:'abcdefghijklmnopq +rstuvwxyzX' -1:0/0 *Fixed:'abcdefghijklmnopqrstuvwxyzX' @ 0 Fl oat: '' @ 0/0 minlen: 27 r->minlen:0 Final program: 1: EXACT <abcdefghijklmnopqrstuvwxyzX> (9) 9: END (0) anchored "abcdefghijklmnopqrstuvwxyzX" at 0 (checking anchored isall) +minlen 27 r->extflags: CHECK_ALL USE_INTUIT_NOML USE_INTUIT_ML Guessing start of match in sv for REx "abcdefghijklmnopqrstuvwxyzX" ag +ainst "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc defgh"... Check offset min: 0 Start shift: 0 End shift 0 Real End Shift: 0 fbm_instr len=157 str=<abcdefghijklmnopqrst> Found anchored substr "abcdefghijklmnopqrstuvwxyzX" at offset 78... Check offset min:0 max:0 S:78 t:78 D:0 end:157 Starting position does not contradict /^/m... Guessed: match at offset 78 Freeing REx: "abcdefghijklmnopqrstuvwxyzX"

So, I don't understand what happens, or how the RE engine is faster than index when they both fire up fbm_instr.


In reply to Re^5: How Index function works?? by Corion
in thread How Index function works?? by saranrsm

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.