aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-28 14:56:13 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-28 14:56:13 -0800
commit4eea68b5a4434c53e3ee828773617a90e8691aad (patch)
tree0f62820869ac18ec3ce12bdd0d436c3a1652dcd2 /function.cpp
parent87429bc03cb3fceef36b2957497992994b0c4f2a (diff)
LRU work to load functions off of the main thread.
We'll have to reevaluate this after we fix function autocomplete
Diffstat (limited to 'function.cpp')
-rw-r--r--function.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/function.cpp b/function.cpp
index ee9c508a..65ddd649 100644
--- a/function.cpp
+++ b/function.cpp
@@ -95,6 +95,7 @@ static int load( const wchar_t *name )
int res;
function_map_t::iterator iter = loaded_functions.find(name);
if( iter != loaded_functions.end() && !iter->second->is_autoload ) {
+ /* We have a non-autoload version already */
return 0;
}
@@ -196,28 +197,23 @@ void function_add( function_data_t *data, const parser_t &parser )
}
}
-static int function_exists_internal( const wchar_t *cmd, bool autoload )
+int function_exists( const wchar_t *cmd )
{
- int res;
CHECK( cmd, 0 );
-
if( parser_keywords_is_reserved(cmd) )
return 0;
-
scoped_lock lock(functions_lock);
- if ( autoload ) load( cmd );
- res = loaded_functions.find(cmd) != loaded_functions.end();
- return res;
-}
-
-int function_exists( const wchar_t *cmd )
-{
- return function_exists_internal( cmd, true );
+ load(cmd);
+ return loaded_functions.find(cmd) != loaded_functions.end();
}
-int function_exists_no_autoload( const wchar_t *cmd )
+int function_exists_no_autoload( const wchar_t *cmd, const env_vars &vars )
{
- return function_exists_internal( cmd, false );
+ CHECK( cmd, 0 );
+ if( parser_keywords_is_reserved(cmd) )
+ return 0;
+ scoped_lock lock(functions_lock);
+ return loaded_functions.find(cmd) != loaded_functions.end() || function_autoloader.can_load(cmd, vars);
}
static bool function_remove_ignore_autoload(const wcstring &name)