This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/9] Come up with an abstraction.


Hi,

On Mon, 10 Jun 2019, Martin Liska wrote:

> 2019-07-24  Martin Liska  <mliska@suse.cz>
> 
> 	* fold-const.c (operand_equal_p): Rename to ...
> 	(operand_compare::operand_equal_p): ... this.
> 	(add_expr):  Rename to ...
> 	(operand_compare::hash_operand): ... this.
> 	(operand_compare::operand_equal_valueize): Likewise.
> 	(operand_compare::hash_operand_valueize): Likewise.
> 	* fold-const.h (operand_equal_p): Set default
> 	value for last argument.
> 	(class operand_compare): New.

Hmpf.  A class without any data?  That doesn't sound like a good design.  
You seem to need it only to have the possibility of virtual functions, 
i.e. fancy callbacks.  AFAICS you only have one derived class, i.e. a 
simple distinction of two cases.  What do you think about encoding the 
additional new (ICF) case in the (existing) 'flags' argument to 
operand_equal_p (and in case the ICF flag is set simply call the 
"callback" directly)?  IMHO that would also make the logic within 
operand_equal_p clearer, because you don't have to think about all the 
potential callback functions that might be called.


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]