Optimized the result of the xsel check, so that it is cached.

It is called very often, and causes a significant performace hit.  The
availability of xsel is not likely to change during the invocation of
the shell.
This commit is contained in:
David Frascone 2010-11-05 09:22:28 -06:00
parent 51b5adc306
commit 93f797326e

14
kill.c
View file

@ -45,19 +45,25 @@ static ll_node_t /** Last kill string */*kill_last=0, /** Current kill string */
static wchar_t *cut_buffer=0;
/**
Test if the xsel command is installed
Test if the xsel command is installed. Since this is called often,
cache the result.
*/
static int has_xsel()
{
static int called=0;
static int res = 0;
if (!called) {
void *context = halloc(0, 0);
wchar_t *path = path_get_path( context, L"xsel" );
int res = !!path;
res = !!path;
halloc_free( context );
called = 1;
}
return res;
}
/**
Add the string to the internal killring
*/