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.
J'
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature
_______________________________________________ pspp-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/pspp-dev
