diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-06-07 12:33:39 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-06-07 12:33:39 +0100 |
| commit | f0285a8e60de3ca27e02e0709646ef7c1302368f (patch) | |
| tree | c464d3ccdd62badeb23a681ec4cdd062c7a480d4 /src/hook_manager.hh | |
| parent | 4606453fedafefc42392c7c78428d8c649319741 (diff) | |
Move hook executing logic into HookManager
The existing HookManager was able to run arbitrary hook functions,
but in practice was only used for user provided textual hooks.
That separation was causing some suboptimal performances, by moving
that logic directly in the hook manager we can improve hook filtering
performance which is a big part of startup time when opening lots
of files.
Diffstat (limited to 'src/hook_manager.hh')
| -rw-r--r-- | src/hook_manager.hh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/hook_manager.hh b/src/hook_manager.hh index e2e238ea..8614b7a5 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -4,19 +4,19 @@ #include "hash_map.hh" #include "completion.hh" #include "safe_ptr.hh" +#include "regex.hh" namespace Kakoune { class Context; -using HookFunc = std::function<void (StringView, Context&)>; class HookManager : public SafeCountable { public: HookManager(HookManager& parent) : m_parent(&parent) {} - void add_hook(StringView hook_name, String group, HookFunc func); + void add_hook(StringView hook_name, String group, Regex filter, String commands); void remove_hooks(StringView group); CandidateList complete_hook_group(StringView prefix, ByteCount pos_in_token); void run_hook(StringView hook_name, StringView param, @@ -31,7 +31,9 @@ private: struct Hook { String group; - HookFunc func; + Regex filter; + MatchResults<const char*> captures; + String commands; }; SafePtr<HookManager> m_parent; |
