Ignore:
Timestamp:
Jul 17, 2017, 2:35:52 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7ebaa56
Parents:
b46e3bd
Message:

Remove Cost constructors, use only named members

This change makes it easier to read code involving costs, since in almost every case, only a single part of the cost tuple is relevant. Furthermore, this change makes it much simpler to add another dimension to the cost tuple, since only Cost.h needs to be updated, rather than every location using the cost constructor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Alternative.cc

    rb46e3bd r89be1c68  
    2828                : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {}
    2929
    30         Alternative::Alternative( const Alternative &other ) {
    31                 initialize( other, *this );
     30        Alternative::Alternative( const Alternative &other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( maybeClone( other.expr ) ), env( other.env ) {
    3231        }
    3332
    3433        Alternative &Alternative::operator=( const Alternative &other ) {
    3534                if ( &other == this ) return *this;
    36                 initialize( other, *this );
     35                delete expr;
     36                cost = other.cost;
     37                cvtCost = other.cvtCost;
     38                expr = maybeClone( other.expr );
     39                env = other.env;
    3740                return *this;
    3841        }
     
    5154                other.expr = nullptr;
    5255                return *this;
    53         }
    54 
    55         void Alternative::initialize( const Alternative &src, Alternative &dest ) {
    56                 dest.cost = src.cost;
    57                 dest.cvtCost = src.cvtCost;
    58                 dest.expr = maybeClone( src.expr );
    59                 dest.env = src.env;
    6056        }
    6157
Note: See TracChangeset for help on using the changeset viewer.