Ignore:
Timestamp:
Mar 30, 2018, 10:36:24 AM (18 months ago)
Author:
cameron
Message:

Direct CC builder work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r5872 r5935  
    240240    unsigned topBit = 1 << (codeUnitWidth - 1);
    241241    unsigned maxCodeVal = (topBit - 1) | topBit;
     242    //
     243    // Optimization if there are isolated codepoints that are not in the set.
     244    UCD::UnicodeSet negatedIsolates = (~(*cc)).isolates();
     245    UCD::UnicodeSet withNegatedIsolates = (*cc + negatedIsolates);
    242246    PabloAST * ccStrm = pb.createZeroes();
    243     for (const auto & interval : *cc) {
     247    for (const auto & interval : withNegatedIsolates) {
    244248        unsigned lo = re::lo_codepoint(interval);
    245249        unsigned hi = re::hi_codepoint(interval);
     
    265269        }
    266270    }
     271    if (!negatedIsolates.empty()) {
     272        PabloAST * toExclude = pb.createZeroes();
     273        for (const auto & interval : negatedIsolates) {
     274            PabloAST * testVal = pb.createRepeat(codeUnitWidth, re::lo_codepoint(interval));
     275            toExclude = pb.createOr(toExclude, pb.createEquals(codeUnitStream, testVal));
     276        }
     277        ccStrm = pb.createAnd(ccStrm, pb.createNot(toExclude));
     278    }
    267279    return ccStrm;
    268280}
Note: See TracChangeset for help on using the changeset viewer.