mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Minor performance tweaks
darcs-hash:20051102154159-ac50b-9a32fb6cc654c593048840ebd9f6abb97c2e0bb8.gz
This commit is contained in:
parent
c8c3715aac
commit
8d58e58d7b
10 changed files with 53 additions and 49 deletions
|
@ -2573,7 +2573,8 @@ static int builtin_end( wchar_t **argv )
|
||||||
parser_get_job_pos()-current_block->tok_pos );
|
parser_get_job_pos()-current_block->tok_pos );
|
||||||
|
|
||||||
//fwprintf( stderr, L"Function: %ls\n", def );
|
//fwprintf( stderr, L"Function: %ls\n", def );
|
||||||
if( !parser_test( def, 1 ) )
|
|
||||||
|
if( !is_interactive || !parser_test( def, 1 ) )
|
||||||
{
|
{
|
||||||
function_add( current_block->param1.function_name,
|
function_add( current_block->param1.function_name,
|
||||||
def,
|
def,
|
||||||
|
|
2
common.c
2
common.c
|
@ -299,7 +299,7 @@ char *wcs2str( const wchar_t *in )
|
||||||
in,
|
in,
|
||||||
MAX_UTF8_BYTES*wcslen(in)+1 );
|
MAX_UTF8_BYTES*wcslen(in)+1 );
|
||||||
|
|
||||||
res = realloc( res, strlen( res )+1 );
|
// res = realloc( res, strlen( res )+1 );
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
20
exec.c
20
exec.c
|
@ -113,21 +113,16 @@ int exec_pipe( int fd[2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug( 4, L"Created pipe using fds %d and %d", fd[0], fd[1]);
|
||||||
|
|
||||||
if( open_fds == 0 )
|
if( open_fds == 0 )
|
||||||
{
|
{
|
||||||
open_fds = malloc( sizeof( array_list_t ) );
|
open_fds = al_new();
|
||||||
if(!open_fds )
|
|
||||||
die_mem();
|
|
||||||
al_init( open_fds );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( res != -1 )
|
|
||||||
{
|
|
||||||
debug( 4, L"Created pipe using fds %d and %d", fd[0], fd[1]);
|
|
||||||
|
|
||||||
al_push( open_fds, (void *)(long)fd[0] );
|
al_push( open_fds, (void *)(long)fd[0] );
|
||||||
al_push( open_fds, (void *)(long)fd[1] );
|
al_push( open_fds, (void *)(long)fd[1] );
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +178,6 @@ static void close_unused_internal_pipes( io_data_t *io )
|
||||||
|
|
||||||
void exec_init()
|
void exec_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_destroy()
|
void exec_destroy()
|
||||||
|
@ -672,7 +666,7 @@ void exec( job_t *j )
|
||||||
pipe_write.io_mode=IO_PIPE;
|
pipe_write.io_mode=IO_PIPE;
|
||||||
pipe_read.next=0;
|
pipe_read.next=0;
|
||||||
pipe_write.next=0;
|
pipe_write.next=0;
|
||||||
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=0;
|
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=-1;
|
||||||
|
|
||||||
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
||||||
|
|
||||||
|
@ -724,6 +718,8 @@ void exec( job_t *j )
|
||||||
|
|
||||||
if( p->next )
|
if( p->next )
|
||||||
{
|
{
|
||||||
|
// debug( 1, L"%ls|%ls" , p->argv[0], p->next->argv[0]);
|
||||||
|
|
||||||
if( exec_pipe( mypipe ) == -1 )
|
if( exec_pipe( mypipe ) == -1 )
|
||||||
{
|
{
|
||||||
debug( 1, PIPE_ERROR );
|
debug( 1, PIPE_ERROR );
|
||||||
|
@ -1051,7 +1047,6 @@ void exec( job_t *j )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if( pid == 0 )
|
if( pid == 0 )
|
||||||
{
|
{
|
||||||
|
@ -1142,7 +1137,6 @@ void exec( job_t *j )
|
||||||
builtin_pop_io();
|
builtin_pop_io();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Close the pipe the current process uses to read from the previous process_t
|
Close the pipe the current process uses to read from the previous process_t
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,7 @@ function _contains_help -d "Helper function for contains"
|
||||||
end
|
end
|
||||||
|
|
||||||
function contains -d "Test if a key is contained in a set of values"
|
function contains -d "Test if a key is contained in a set of values"
|
||||||
while count $argv >/dev/null
|
while set -q argv
|
||||||
switch $argv[1]
|
switch $argv[1]
|
||||||
case '-h' '--h' '--he' '--hel' '--help'
|
case '-h' '--h' '--he' '--hel' '--help'
|
||||||
_contains_help
|
_contains_help
|
||||||
|
@ -56,8 +56,7 @@ function contains -d "Test if a key is contained in a set of values"
|
||||||
set -e argv[1]
|
set -e argv[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
if count $argv >/dev/null
|
if not set -q argv
|
||||||
else
|
|
||||||
echo "contains: Key not specified"
|
echo "contains: Key not specified"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,7 +58,7 @@ function set_default_color -d "Set an universal variable, unless it has already
|
||||||
set -U -- $argv
|
set -U -- $argv
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if contains $$argv[1] (set_color --print-colors)
|
if contains -- $$argv[1] (set_color --print-colors)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
set -U -- $argv
|
set -U -- $argv
|
||||||
|
|
1
io.c
1
io.c
|
@ -95,7 +95,6 @@ io_data_t *io_buffer_create()
|
||||||
b_init( buffer_redirect->param2.out_buffer );
|
b_init( buffer_redirect->param2.out_buffer );
|
||||||
buffer_redirect->fd=1;
|
buffer_redirect->fd=1;
|
||||||
|
|
||||||
|
|
||||||
if( exec_pipe( buffer_redirect->param1.pipe_fd ) == -1 )
|
if( exec_pipe( buffer_redirect->param1.pipe_fd ) == -1 )
|
||||||
{
|
{
|
||||||
debug( 1, PIPE_ERROR );
|
debug( 1, PIPE_ERROR );
|
||||||
|
|
1
main.c
1
main.c
|
@ -212,6 +212,7 @@ int main( int argc, char **argv )
|
||||||
output_init();
|
output_init();
|
||||||
event_init();
|
event_init();
|
||||||
exec_init();
|
exec_init();
|
||||||
|
wutil_init();
|
||||||
parser_init();
|
parser_init();
|
||||||
builtin_init();
|
builtin_init();
|
||||||
function_init();
|
function_init();
|
||||||
|
|
2
signal.c
2
signal.c
|
@ -500,5 +500,3 @@ void signal_unblock()
|
||||||
|
|
||||||
sigprocmask(SIG_UNBLOCK, &chldset, 0);
|
sigprocmask(SIG_UNBLOCK, &chldset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
10
wutil.c
10
wutil.c
|
@ -22,6 +22,8 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "wutil.h"
|
#include "wutil.h"
|
||||||
|
|
||||||
|
#define TMP_LEN_MIN 256
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Buffer for converting wide arguments to narrow arguments, used by
|
Buffer for converting wide arguments to narrow arguments, used by
|
||||||
the \c wutil_wcs2str() function.
|
the \c wutil_wcs2str() function.
|
||||||
|
@ -37,6 +39,10 @@ static size_t tmp_len=0;
|
||||||
*/
|
*/
|
||||||
static int wutil_calls = 0;
|
static int wutil_calls = 0;
|
||||||
|
|
||||||
|
void wutil_init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void wutil_destroy()
|
void wutil_destroy()
|
||||||
{
|
{
|
||||||
free( tmp );
|
free( tmp );
|
||||||
|
@ -57,8 +63,8 @@ static char *wutil_wcs2str( const wchar_t *in )
|
||||||
size_t new_sz =MAX_UTF8_BYTES*wcslen(in)+1;
|
size_t new_sz =MAX_UTF8_BYTES*wcslen(in)+1;
|
||||||
if( tmp_len < new_sz )
|
if( tmp_len < new_sz )
|
||||||
{
|
{
|
||||||
free( tmp );
|
new_sz = maxi( new_sz, TMP_LEN_MIN );
|
||||||
tmp = malloc( new_sz );
|
tmp = realloc( tmp, new_sz );
|
||||||
if( !tmp )
|
if( !tmp )
|
||||||
{
|
{
|
||||||
die_mem();
|
die_mem();
|
||||||
|
|
6
wutil.h
6
wutil.h
|
@ -14,6 +14,12 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Call this function on startup to create internal wutil
|
||||||
|
resources. This function doesn't do anything.
|
||||||
|
*/
|
||||||
|
void wutil_init();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call this function on exit to free internal wutil resources
|
Call this function on exit to free internal wutil resources
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue