John Darrington <[email protected]> writes: > On Sat, Dec 04, 2010 at 11:37:38AM -0800, Ben Pfaff wrote: > > Reducing code duplication is good on its own. This will also make it > easier in upcoming patches to swap out "getl_interface" with a new > structure, by eliminating most of the references to getl_interface. > > +/* Executes null-terminated string SYNTAX as syntax. > + Returns SYNTAX. */ > +gchar * > +execute_syntax_string (gchar *syntax) > +{ > + struct getl_interface *sss = create_syntax_string_source (syntax); > + execute_syntax (sss); > + return syntax; > +} > + > +/* Executes null-terminated string SYNTAX as syntax. > + Returns SYNTAX. */ > +const gchar * > +execute_const_syntax_string (const gchar *syntax) > +{ > + return execute_syntax_string (CONST_CAST (gchar *, syntax)); > +} > > These functions can be written as: > > /* Executes null-terminated string SYNTAX as syntax. > Returns SYNTAX. */ > gchar * > execute_syntax_string (gchar *syntax) > { > execute_const_syntax_string (syntax); > return syntax; > } > > /* Executes null-terminated string SYNTAX as syntax. > Returns SYNTAX. */ > const gchar * > execute_const_syntax_string (const gchar *syntax) > { > execute_syntax (create_syntax_string_source (syntax)); > return syntax; > } > > > .. which avoids the CONST_CAST, and a reference to getl_interface. > Optionally, you could make the second function return void, since > nowhere is its return value used.
That's much better, thanks. I folded both changes into this commit. Should I wait for other comments on these changes, or are you satisfied with them? Thanks, Ben. -- "Because computer source code is an expressive means for the exchange of information and ideas about computer programming, we hold that it is protected by the First Amendment." --Hon. Boyce F. Martin, Jr., for the 6th Circuit Court, Junger vs. Daley _______________________________________________ pspp-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/pspp-dev
