Replace the count function with a builtin for performance reasons. The count function used at least two forks, which was noticable on systems such as OS X with slow forks

darcs-hash:20070731212332-ac50b-8f5b2e70008ddb131dc8bae3f361d8d65a294948.gz
This commit is contained in:
axel
2007-08-01 07:23:32 +10:00
parent 748d726ddf
commit 91de143003
5 changed files with 37 additions and 43 deletions

View File

@@ -1401,18 +1401,17 @@ static void parse_job_argument_list( process_t *p,
if( !skip )
{
if( proc_is_count &&
(al_get_count( args) == 1) &&
( parser_is_help( tok_last(tok), 0) ) )
if( ( proc_is_count ) &&
( al_get_count( args) == 1) &&
( parser_is_help( tok_last(tok), 0) ) &&
( p->type == INTERNAL_BUILTIN ) )
{
/*
Display help for count
*/
p->type = INTERNAL_BUILTIN;
p->actual_cmd = L"count";
p->count_help_magic = 1;
}
switch( expand_string( j, wcsdup(tok_last( tok )), args, 0 ) )
{
case EXPAND_ERROR:
@@ -1421,9 +1420,9 @@ static void parse_job_argument_list( process_t *p,
if( error_code == 0 )
{
error( SYNTAX_ERROR,
tok_get_pos( tok ),
_(L"Could not expand string '%ls'"),
tok_last(tok) );
tok_get_pos( tok ),
_(L"Could not expand string '%ls'"),
tok_last(tok) );
}
break;