Changeset 17f22e78


Ignore:
Timestamp:
Jul 21, 2017, 9:47:10 AM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
cb43451
Parents:
9a34b5a
Message:

Update Cost operations to perform infinity checks internally

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Cost.h

    r9a34b5a r17f22e78  
    5757
    5858        inline Cost & Cost::incUnsafe( int inc ) {
     59                if ( *this == infinity ) return *this;
    5960                unsafeCost += inc;
    6061                return *this;
     
    6263
    6364        inline Cost & Cost::incPoly( int inc ) {
     65                if ( *this == infinity ) return *this;
    6466                polyCost += inc;
    6567                return *this;
     
    6769
    6870        inline Cost & Cost::incSafe( int inc ) {
     71                if ( *this == infinity ) return *this;
    6972                safeCost += inc;
    7073                return *this;
     
    7275
    7376        inline Cost & Cost::incReference( int inc ) {
     77                if ( *this == infinity ) return *this;
    7478                referenceCost += inc;
    7579                return *this;
     
    7781
    7882        inline Cost Cost::operator+( const Cost &other ) const {
     83                if ( *this == infinity || other == infinity ) return infinity;
    7984                return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost, referenceCost + other.referenceCost );
    8085        }
    8186
    8287        inline Cost Cost::operator-( const Cost &other ) const {
     88                if ( *this == infinity || other == infinity ) return infinity;
    8389                return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost, referenceCost - other.referenceCost );
    8490        }
    8591
    8692        inline Cost &Cost::operator+=( const Cost &other ) {
     93                if ( *this == infinity ) return *this;
     94                if ( other == infinity ) {
     95                        *this = infinity;
     96                        return *this;
     97                }
    8798                unsafeCost += other.unsafeCost;
    8899                polyCost += other.polyCost;
Note: See TracChangeset for help on using the changeset viewer.