mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 15:01:16 -03: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:
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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user