Hello, Sean!
This's my summary about duplications in one file and my suggestions. Sorry,
it's too big =), but I wanted to write everything in details. So, will wait
for your comments to this summary and my patches.
/tab/tabinterp.c - functions step_interpolate and linear_interpolate -- the
bodies're different but part which contains "for", "while" and "if" can be
put in common static inline function.

/rt/worker.c - there're two huge parts in function "void do_pixel" in
"begin unroll"-"end unroll" and "begin non-ubrolled"-"end non-unrolled".
However, you told it problem file, so I'll wait your comment here.

/mged/cmd.c - functions "int cmd_ged_edit_wrapper" and "int
cmd_ged_simulate_wrapper". The only ddifference is value of av[1]. Both
these functions are used in setup.c, so it's better to use static inline
function too. I suggest to make one more variable for parameter of argv[]

/libtclcad/tclcadobj.c -
*functions "HIDDEN int to_mouse_move_arb_edge", "HIDDEN int
to_mouse_move_arb_face" and "HIDDEN int to_mouse_move_pipept". The
difference's in:
av[0] = "move_arb_face"; - to_mouse_move_arb_face
av[0] = "move_arb_edge"; - to_mouse_move_arb_edge
av[0] = "move_pipept"; - to_mouse_move_pipept

and
ret = ged_move_arb_edge(gedp, 5, (const char **)av);
ret = ged_move_arb_face(gedp, 5, (const char **)av);
ret = ged_move_pipept(gedp, 5, (const char **)av);

So these functions could call another static function which'd have all the
body and get char * parameter for av[0] and functional type for ret.
*functions "HIDDEN int to_poly_ell_mode" and "HIDDEN int
to_poly_circ_mode". Differnce's in consts - gdvp->gdv_view->gv_mode =
TCLCAD_POLY_ELLIPSE_MODE; and gdvp->gdv_view->gv_mode =
TCLCAD_POLY_CIRCLE_MODE; so necessary const could be got by common function
(type - ged_view, if I'm not mistaken). Also difference is in
bu_vls_printf, but type char* can be transmit too.

/librt/primitives/nmg/nmg_rt_segs.c - functions "HIDDEN int state5" and
"HIDDEN int state6". It'd be easy to reduct, because difference's only in
ret_val (in two situations at the end of functions) which is INT. So I'd be
necessary only to transmit ret_val1 and ret_val2.

/libpc/pcParameter.cpp - methods Point::Point(VCSet & vcs, std::string n,
void *ptr) and Vector::Vector(VCSet & vcs, std::string n, void *ptr): the
blocks in if (ptr) {...} are the same, so this block can be put in other
function.

/liboptical/sh_camo.c - functions HIDDEN int marble_setup and HIDDEN int
camo_setup. The difference is in bu_log (just static comment) and in
memcpy.

/libbn/plot.c - functions void pd_3space and void pd_3line. I made static
inline function pd_3 which gets the same parameters as those two functions
+ char l. Both functions call pd_3 with l == 'W' for pd3_space and l == 'V'
for pd_3line. Making was successful.

/fbserv/server.c - void fb_server_fb_scursor and void fb_server_fb_cursor.
Difference is:
(void)pkg_plong(&rbuf[0], fb_cursor(fb_server_fbp, mode, x, y)); and
(void)pkg_plong(&rbuf[0], fb_scursor(fb_server_fbp, mode, x, y));
So common function can get just: struct pkg_conn *pcp, char *buf +
functional type

/fb/pl-fb.c - int GetDCoords(coords *coop) and int Get3DCoords(coords
*coop). Difference is only here: if (debug) {fprintf..}. So text for
fprintf can be transmited like a char * in common function.

Thanks, Ksenija
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to