Ignore:
Timestamp:
Jan 15, 2018, 4:48:02 PM (13 months ago)
Author:
nmedfort
Message:

Revised RE_Minimizer to use alphabets + minor optimizations to RE functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_seq.h

    r5810 r5835  
    2424protected:
    2525    friend Seq * makeSeq();
    26     template<typename iterator> friend RE * makeSeq(iterator, iterator);
     26    template<typename iterator> friend RE * makeSeq(const iterator, const iterator);
    2727    Seq()
    2828    : Vector(ClassTypeId::Seq) {
     
    3333
    3434    }
    35     template<typename itr> void flatten(itr begin, itr end);
    3635};
    3736
     
    4039}
    4140
    42 template<typename itr>
    43 void Seq::flatten(itr begin, itr end) {
     41template<typename iterator>
     42inline RE * makeSeq(const iterator begin, const iterator end) {
     43    Seq * seq = makeSeq();
    4444    for (auto i = begin; i != end; ++i) {
    45         if (LLVM_UNLIKELY(llvm::isa<Seq>(*i))) {
    46             flatten<Seq::iterator>(llvm::cast<Seq>(*i)->begin(), llvm::cast<Seq>(*i)->end());
     45        RE * const item = *i;
     46        if (LLVM_UNLIKELY(llvm::isa<Seq>(item))) {
     47            for (RE * const innerItem : *llvm::cast<Seq>(item)) {
     48                seq->push_back(innerItem);
     49            }
    4750        } else {
    48             push_back(*i);
     51            seq->push_back(item);
    4952        }
    5053    }
    51 }
    52 
    53 template<typename itr>
    54 inline RE * makeSeq(itr begin, itr end) {
    55     if (LLVM_UNLIKELY(std::distance(begin, end) == 0)) {
    56         return makeSeq();
    57     } else {
    58         Seq * seq = makeSeq();
    59         seq->flatten(begin, end);
    60         if (seq->size() == 1) {
    61             return seq->front();
    62         }
    63         return seq;
     54    if (seq->size() == 1) {
     55        return seq->front();
    6456    }
     57    return seq;
    6558}
    6659
Note: See TracChangeset for help on using the changeset viewer.