Ignore:
Timestamp:
Nov 28, 2017, 1:45:19 AM (22 months ago)
Author:
nmedfort
Message:

Bug fix for segment pipeline parallel mode + memory management improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.cpp

    r5694 r5748  
    1717#include <util/aligned_allocator.h>
    1818#include <re/re_analysis.h>
     19#include <re/re_cc.h>
     20
    1921using namespace llvm;
    2022
     
    9496    alloc.deallocate(aligned, 0);
    9597   
    96     UnicodeSet a = UnicodeSet();
    97     for (auto v : accumulatedValues) {
     98    UnicodeSet a;
     99    for (const auto & v : accumulatedValues) {
    98100        int e = GetPropertyValueEnumCode(v);
    99         a = a + GetCodepointSet(e);
     101        a.insert(GetCodepointSet(e));
    100102    }
    101103    return a;
     
    118120        }
    119121        for (unsigned i = 0; i < basis_count; i++) {
    120             enumeration_basis_sets.push_back(UnicodeSet());
     122            enumeration_basis_sets.push_back(std::move(UnicodeSet()));
    121123            for (unsigned e = 0; e < independent_enum_count; e++) {
    122124                if (((e >> i) & 1UL) == 0) {
     
    217219    alloc.deallocate(aligned, 0);
    218220   
    219     UnicodeSet a = UnicodeSet();
    220     for (auto v : accumulatedValues) {
     221    UnicodeSet a;
     222    for (const auto & v : accumulatedValues) {
    221223        int e = baseObj->GetPropertyValueEnumCode(v);
    222         a = a + GetCodepointSet(e);
     224        a.insert(GetCodepointSet(e));
    223225    }
    224226    return a;
     
    290292public:
    291293   
    292     SetByLineNumberAccumulator(const std::vector<UCD::codepoint_t> & cps, UnicodeSet defaultValueSet)
    293     : mCodepointTableByLineNum(cps), mDefaultValueSet(defaultValueSet) {}
     294    SetByLineNumberAccumulator(const std::vector<UCD::codepoint_t> & cps, const UnicodeSet & defaultValueSet)
     295    : mCodepointTableByLineNum(cps)
     296    , mDefaultValueSet(defaultValueSet) {
     297
     298    }
    294299   
    295300    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
    296     UnicodeSet getAccumulatedSet() { return mAccumSet; }
     301    UnicodeSet && getAccumulatedSet() { return std::move(mAccumSet); }
    297302private:
    298303    const std::vector<UCD::codepoint_t> & mCodepointTableByLineNum;
    299     UnicodeSet mDefaultValueSet;
     304    const UnicodeSet & mDefaultValueSet;
    300305    UnicodeSet mAccumSet;
    301306};
    302 void SetByLineNumberAccumulator::accumulate_match(const size_t lineNum, char * line_start, char * line_end) {
    303     if (lineNum >= mCodepointTableByLineNum.size()) mAccumSet = mAccumSet + mDefaultValueSet;
    304     else mAccumSet.insert(mCodepointTableByLineNum[lineNum]);
    305 }
    306 
     307
     308void SetByLineNumberAccumulator::accumulate_match(const size_t lineNum, char * /* line_start */, char * /* line_end */) {
     309    if (lineNum >= mCodepointTableByLineNum.size()) {
     310        mAccumSet.insert(mDefaultValueSet);
     311    } else {
     312        mAccumSet.insert(mCodepointTableByLineNum[lineNum]);
     313    }
     314}
    307315
    308316const UnicodeSet NumericPropertyObject::GetCodepointSet(const std::string & value_spec) {
    309     if (value_spec == "NaN") return mNaNCodepointSet;
    310     else {
    311         UnicodeSet result_set = UnicodeSet();
     317    if (value_spec == "NaN") {
     318        return mNaNCodepointSet;
     319    } else {
     320        UnicodeSet result_set;
    312321        unsigned val_bytes = value_spec.length();
    313322        const char * value_str = value_spec.c_str();
     
    328337
    329338const UnicodeSet NumericPropertyObject::GetCodepointSetMatchingPattern(re::RE * pattern) {
    330     UnicodeSet matched;
    331339    SetByLineNumberAccumulator accum(mExplicitCps, mNaNCodepointSet);
    332     grepBuffer(pattern, mStringBuffer, mBufSize, & accum);
    333     return matched + accum.getAccumulatedSet();
     340    grepBuffer(pattern, mStringBuffer, mBufSize, &accum);
     341    return accum.getAccumulatedSet();
    334342}
    335343
    336344
    337345const UnicodeSet StringPropertyObject::GetCodepointSet(const std::string & value_spec) {
    338     if (value_spec == "") return mNullCodepointSet;
    339     else {
    340         UnicodeSet result_set = UnicodeSet();
     346    if (value_spec.empty()) {
     347        return mNullCodepointSet;
     348    } else {
     349        UnicodeSet result_set;
    341350        unsigned val_bytes = value_spec.length();
    342351        codepoint_t cp;
     
    363372
    364373const UnicodeSet StringPropertyObject::GetCodepointSetMatchingPattern(re::RE * pattern) {
    365     UnicodeSet matched = *cast<UnicodeSet>(matchableCodepoints(pattern)) & mSelfCodepointSet;
     374    UnicodeSet matched(*matchableCodepoints(pattern) & mSelfCodepointSet);
    366375    if (re::matchesEmptyString(pattern)) {
    367         matched = matched + mNullCodepointSet;
     376        matched.insert(mNullCodepointSet);
    368377    }
    369378    SetByLineNumberAccumulator accum(mExplicitCps, mNullCodepointSet);
    370     grepBuffer(pattern, mStringBuffer, mBufSize, & accum);
    371     return matched + accum.getAccumulatedSet();
     379    grepBuffer(pattern, mStringBuffer, mBufSize, & accum);   
     380    matched.insert(accum.getAccumulatedSet());
     381    return matched;
    372382}
    373383   
     
    401411    SetByLineNumberAccumulator accum(mExplicitCps, UnicodeSet());
    402412    grepBuffer(pattern, mStringBuffer, mBufSize, & accum);
    403     return base_set + accum.getAccumulatedSet();
     413    base_set.insert(accum.getAccumulatedSet());
     414    return base_set;
    404415}
    405416
Note: See TracChangeset for help on using the changeset viewer.