Yet more tracking

This commit is contained in:
Maxime Coste 2015-01-12 13:45:44 +00:00
parent f1f10639a5
commit 83d0813b0f
9 changed files with 24 additions and 16 deletions

View File

@ -70,7 +70,7 @@ private:
DisplayLine m_pending_status_line;
DisplayLine m_mode_line;
std::vector<Key> m_pending_keys;
Vector<Key> m_pending_keys;
};
}

View File

@ -50,7 +50,7 @@ public:
ByteCount pos_in_token) const;
private:
std::vector<ArgumentCompleter> m_completers;
Vector<ArgumentCompleter, MemoryDomain::Commands> m_completers;
};
using CommandInfo = std::pair<String, String>;
@ -88,7 +88,7 @@ private:
CommandFlags flags;
CommandCompleter completer;
};
using CommandMap = UnorderedMap<String, CommandDescriptor>;
using CommandMap = UnorderedMap<String, CommandDescriptor, MemoryDomain::Commands>;
CommandMap m_commands;
CommandMap::const_iterator find_command(const Context& context,

View File

@ -833,9 +833,13 @@ const CommandDesc debug_cmd = {
auto options = UsedMemory<MemoryDomain::Options>::byte_count;
auto highlight = UsedMemory<MemoryDomain::Highlight>::byte_count;
auto word_db = UsedMemory<MemoryDomain::WordDB>::byte_count;
auto mapping = UsedMemory<MemoryDomain::Mapping>::byte_count;
auto commands = UsedMemory<MemoryDomain::Commands>::byte_count;
auto hooks = UsedMemory<MemoryDomain::Hooks>::byte_count;
auto undefined = UsedMemory<MemoryDomain::Undefined>::byte_count;
auto total = string + interned_string + buffer_content + buffer_meta + options + highlight + word_db + undefined;
auto total = string + interned_string + buffer_content + buffer_meta +
options + highlight + word_db + mapping + commands + hooks + undefined;
write_debug("Memory usage:");
write_debug("String: " + to_string(string));
@ -845,6 +849,9 @@ const CommandDesc debug_cmd = {
write_debug("Options: " + to_string(options));
write_debug("Highlight: " + to_string(highlight));
write_debug("WordDB: " + to_string(word_db));
write_debug("Mapping: " + to_string(mapping));
write_debug("Commands: " + to_string(commands));
write_debug("Hooks: " + to_string(hooks));
write_debug("Undefined: " + to_string(undefined));
write_debug("Total: " + to_string(total));
write_debug("Malloced: " + to_string(mallinfo().uordblks));

View File

@ -29,7 +29,7 @@ private:
friend class Scope;
HookManager* m_parent;
UnorderedMap<String, IdMap<HookFunc>> m_hook;
UnorderedMap<String, IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook;
};
}

View File

@ -4,8 +4,7 @@
#include "keys.hh"
#include "hash.hh"
#include "unordered_map.hh"
#include <vector>
#include "vector.hh"
namespace Kakoune
{
@ -29,7 +28,7 @@ class KeymapManager
public:
KeymapManager(KeymapManager& parent) : m_parent(&parent) {}
using KeyList = std::vector<Key>;
using KeyList = Vector<Key, MemoryDomain::Mapping>;
void map_key(Key key, KeymapMode mode, KeyList mapping);
void unmap_key(Key key, KeymapMode mode);
@ -44,7 +43,7 @@ private:
KeymapManager* m_parent;
using KeyAndMode = std::pair<Key, KeymapMode>;
using Keymap = UnorderedMap<KeyAndMode, KeyList>;
using Keymap = UnorderedMap<KeyAndMode, KeyList, MemoryDomain::Mapping>;
Keymap m_mapping;
};

View File

@ -4,8 +4,7 @@
#include "unicode.hh"
#include "flags.hh"
#include "hash.hh"
#include <vector>
#include "vector.hh"
namespace Kakoune
{
@ -67,7 +66,7 @@ struct Key
template<> struct WithBitOps<Key::Modifiers> : std::true_type {};
using KeyList = std::vector<Key>;
using KeyList = Vector<Key, MemoryDomain::Mapping>;
class String;
class StringView;

View File

@ -17,6 +17,9 @@ enum class MemoryDomain
BufferMeta,
Options,
Highlight,
Mapping,
Commands,
Hooks,
WordDB
};

View File

@ -40,7 +40,7 @@ struct SwitchDesc
String description;
};
using SwitchMap = IdMap<SwitchDesc>;
using SwitchMap = IdMap<SwitchDesc, MemoryDomain::Commands>;
String generate_switches_doc(const SwitchMap& opts);
@ -146,7 +146,7 @@ struct ParametersParser
private:
ParameterList m_params;
std::vector<size_t> m_positional_indices;
Vector<size_t, MemoryDomain::Commands> m_positional_indices;
const ParameterDesc& m_desc;
};

View File

@ -138,7 +138,7 @@ void test_string()
void test_keys()
{
std::vector<Key> keys{
KeyList keys{
{ ' ' },
{ 'c' },
{ Key::Modifiers::Alt, 'j' },