Algorithm-AhoCorasick-XS

 view release on metacpan or  search on metacpan

Matcher.cpp  view on Meta::CPAN

            for (Trie *child: n->children) {
                while (child) {
                    queue.push(child);
                    child = child->next;
                }
            }

            // root's fail function is root
            if (n == root) continue;

            // Follow fail function from parent to find the longest suffix
            // (or reach the root)
            Trie *fail = n->parent->fail;
            while (fail->get_child(n->label) == nullptr && fail != root) {
                fail = fail->fail;
            }

            // We found the suffix...
            n->fail = fail->get_child(n->label);

            // ??
            if (n->fail == nullptr) n->fail = root;
            if (n->fail == n) n->fail = root;

Trie.hpp  view on Meta::CPAN


        unsigned char label = '\0';
        // Empirically, an array of 8 delivers a good compromise between
        // speed and memory usage.
        Trie *children[8] = {nullptr};
        Trie *next = nullptr;

        // Extensions for AC automaton
        Trie *fail = nullptr;
        std::forward_list<int> out;
        Trie *parent = nullptr;

        Trie() {}
        Trie(unsigned char label, Trie *parent) : label(label), parent(parent) {}

        static int bucket(unsigned char ch) {
            return ch & 7;  // Mask all but last 3 bytes
        }

        Trie *get_child(unsigned char ch) {
            Trie *child = children[ bucket(ch) ];
            if (!child) return nullptr;
            else {
                while (child) {

ppport.h  view on Meta::CPAN

op_clear|||
op_contextualize||5.013006|
op_convert_list||5.021006|
op_dump||5.006000|
op_free|||
op_integerize|||
op_linklist||5.013006|
op_lvalue_flags|||
op_lvalue||5.013007|
op_null||5.007002|
op_parent|||n
op_prepend_elem||5.013006|
op_refcnt_dec|||
op_refcnt_inc|||
op_refcnt_lock||5.009002|
op_refcnt_unlock||5.009002|
op_relocate_sv|||
op_scope||5.013007|
op_sibling_splice||5.021002|n
op_std_init|||
op_unscope|||

ppport.h  view on Meta::CPAN


#ifndef OpSIBLING
#  define OpSIBLING(o)                   (0 + (o)->op_sibling)
#endif

#ifndef OpMORESIB_set
#  define OpMORESIB_set(o, sib)          ((o)->op_sibling = (sib))
#endif

#ifndef OpLASTSIB_set
#  define OpLASTSIB_set(o, parent)       ((o)->op_sibling = NULL)
#endif

#ifndef OpMAYBESIB_set
#  define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib))
#endif

#ifndef SvRX
#if defined(NEED_SvRX)
static void * DPPP_(my_SvRX)(pTHX_ SV *rv);
static
#else
extern void * DPPP_(my_SvRX)(pTHX_ SV *rv);
#endif



( run in 0.481 second using v1.01-cache-2.11-cpan-4d50c553e7e )