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

Potential bug fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.