mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
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:
parent
51b5adc306
commit
93f797326e
1 changed files with 13 additions and 7 deletions
20
kill.c
20
kill.c
|
@ -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()
|
||||
{
|
||||
void *context = halloc(0, 0);
|
||||
wchar_t *path = path_get_path( context, L"xsel" );
|
||||
int res = !!path;
|
||||
halloc_free( context );
|
||||
static int called=0;
|
||||
static int res = 0;
|
||||
|
||||
if (!called) {
|
||||
void *context = halloc(0, 0);
|
||||
wchar_t *path = path_get_path( context, L"xsel" );
|
||||
res = !!path;
|
||||
halloc_free( context );
|
||||
called = 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Add the string to the internal killring
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue