-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
refactorThis code needs a refactoringThis code needs a refactoring
Description
Lines 87 to 110 in 19a9d73
| /* | |
| FIXME: the following codes have this shape: | |
| if (arg equals to opt_1) { | |
| // tests to see if it is fine to take this arg | |
| // sets the option | |
| } | |
| else if (arg equals to opt_2) { ... } | |
| It seems it is possible to refactor like so: | |
| opts = [opt_1, opt_2, ...] | |
| handlers = [opt_1_handler, opt_2_handler, ...] | |
| for (until the end of args) { | |
| // checks whether arg is in opts; if exists, gets the index | |
| // invokes the corresponding handler: handlers[index]() | |
| } | |
| void opt_n_handler(optflg_t *of) { | |
| // tests to see if it is fine to take this arg | |
| // sets the option | |
| } | |
| */ |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
refactorThis code needs a refactoringThis code needs a refactoring