Changeset 4823


Ignore:
Timestamp:
Oct 5, 2015, 12:58:05 PM (2 years ago)
Author:
nmedfort
Message:

Potential bug fix

Location:
icGREP/icgrep-devel/icgrep/re
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_memoizer.hpp

    r4820 r4823  
    1616            return *cast<Name>(lh) < *cast<CC>(rh);
    1717        }
    18         return !(*cast<Name>(rh) < *cast<CC>(lh));
     18        return *cast<Name>(rh) > *cast<CC>(lh);
    1919    }
    2020};
     
    2929            return cast<Name>(*f);
    3030        } else {
    31             Name * name = makeName(cc->canonicalName(CC_type::UnicodeClass), cc);
     31            Name * name = makeName(cc);
    3232            insert(name);
    3333            return name;
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4819 r4823  
    4444    bool operator<(const Name & other) const;
    4545    bool operator<(const CC & other) const;
     46    bool operator>(const CC & other) const;
    4647    void setDefinition(RE * definition);
    4748    virtual ~Name() {}
    4849protected:
    49     friend Name * makeName(const std::string &, RE *);
     50    friend Name * makeName(const std::string & name, RE * cc);
     51    friend Name * makeName(CC * const cc);
    5052    friend Name * makeName(const std::string &, const Type);
    5153    friend Name * makeName(const std::string &, const std::string &, const Type);
     
    107109
    108110inline bool Name::operator < (const Name & other) const {
    109     if (mDefinition && other.mDefinition && isa<CC>(mDefinition) && isa<CC>(other.mDefinition)) {
     111    if (LLVM_LIKELY(mDefinition && other.mDefinition && isa<CC>(mDefinition) && isa<CC>(other.mDefinition))) {
    110112        return *cast<CC>(mDefinition) < *cast<CC>(other.mDefinition);
    111113    } else if (mNamespaceLength < other.mNamespaceLength) {
     
    134136}
    135137
     138inline bool Name::operator > (const CC & other) const {
     139    if (mDefinition && isa<CC>(mDefinition)) {
     140        return other < *cast<CC>(mDefinition);
     141    }
     142    return true;
     143}
     144
    136145inline Name * makeName(const std::string & name, const Name::Type type) {
    137146    return new Name(nullptr, 0, name.c_str(), name.length(), type, nullptr);
     
    153162}
    154163
     164inline Name * makeName(CC * const cc) {
     165    const bool ascii = cc->max_codepoint() <= 0x7F;
     166    const std::string name = cc->canonicalName(ascii ? CC_type::ByteClass : CC_type::UnicodeClass);
     167    return new Name(nullptr, 0, name.c_str(), name.length(), ascii ? Name::Type::Byte : Name::Type::Unicode, cc);
     168}
     169
    155170}
    156171
Note: See TracChangeset for help on using the changeset viewer.