ash: speed up NOFORK code in ash by eliminating second find_applet().
some code reduction along the way. function old new delta run_list 1971 1981 +10 run_nofork_applet_prime 181 182 +1 unsetcmd 97 96 -1 delete_cmd_entry 54 53 -1 describe_command 399 397 -2 cmdlookup 152 150 -2 evaltreenr 602 599 -3 evaltree 602 599 -3 clearcmdentry 101 98 -3 cdcmd 675 672 -3 hashcmd 305 301 -4 find_command 933 910 -23 evalcommand 1371 1229 -142 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/11 up/down: 11/-187) Total: -176 bytes
This commit is contained in:
@@ -146,6 +146,15 @@ int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **
|
||||
memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0]));
|
||||
/* Finally we can call NOFORK applet's main() */
|
||||
rc = applet_main[applet_no](argc, tmp_argv);
|
||||
|
||||
/* The whole reason behind nofork_save_area is that <applet>_main
|
||||
* may exit non-locally! For example, in hush Ctrl-Z tries to
|
||||
* (modulo bugs) to dynamically create child (backgrounded task)
|
||||
* if it detects that Ctrl-Z was pressed when a NOFORK was running!
|
||||
* Testcase: interactive "rm -i".
|
||||
* Don't fool yourself into thinking "and <applet>_main() returns
|
||||
* quickly here" and removing "useless" nofork_save_area code. */
|
||||
|
||||
} else { /* xfunc died in NOFORK applet */
|
||||
/* in case they meant to return 0... */
|
||||
if (rc == -2222)
|
||||
@@ -154,7 +163,7 @@ int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **
|
||||
|
||||
/* Restoring globals */
|
||||
restore_nofork_data(old);
|
||||
return rc;
|
||||
return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
|
||||
}
|
||||
|
||||
int run_nofork_applet(int applet_no, char **argv)
|
||||
|
Reference in New Issue
Block a user