summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-01-11 19:28:03 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-01-11 19:28:03 +0000
commitdedb16bc73372eb45a24925590ecc8273e4efabf (patch)
treea364af5987e29e87b594f0104ded002cf0fcf32b /src
parent9adb97ea288e08bf9d098fc195aaf8c0f9a27c3e (diff)
Track some more memory
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc2
-rw-r--r--src/interned_string.hh2
-rw-r--r--src/unit_tests.cc6
-rw-r--r--src/word_db.cc2
-rw-r--r--src/word_db.hh4
5 files changed, 9 insertions, 7 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 3dced933..34e14967 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <malloc.h>
namespace Kakoune
{
@@ -832,6 +833,7 @@ const CommandDesc debug_cmd = {
write_debug("BufferMeta: " + to_string(UsedMemory<MemoryDomain::BufferMeta>::byte_count));
write_debug("WordDB: " + to_string(UsedMemory<MemoryDomain::WordDB>::byte_count));
write_debug("Undefined: " + to_string(UsedMemory<MemoryDomain::Undefined>::byte_count));
+ write_debug("Malloced: " + to_string(mallinfo().uordblks));
}
else
throw runtime_error("unknown debug command '" + parser[0] + "'");
diff --git a/src/interned_string.hh b/src/interned_string.hh
index 25c84a85..8357ba85 100644
--- a/src/interned_string.hh
+++ b/src/interned_string.hh
@@ -20,7 +20,7 @@ private:
void acquire(size_t slot);
void release(size_t slot) noexcept;
- UnorderedMap<StringView, size_t> m_slot_map;
+ UnorderedMap<StringView, size_t, MemoryDomain::InternedString> m_slot_map;
Vector<size_t, MemoryDomain::InternedString> m_free_slots;
struct DataAndRefCount
{
diff --git a/src/unit_tests.cc b/src/unit_tests.cc
index 845b9a3e..d4a78784 100644
--- a/src/unit_tests.cc
+++ b/src/unit_tests.cc
@@ -82,17 +82,17 @@ void test_word_db()
WordDB word_db(buffer);
auto res = word_db.find_matching("", prefix_match);
std::sort(res.begin(), res.end());
- kak_assert(res == std::vector<InternedString>{ "allo" COMMA "kanaky" COMMA "mutch" COMMA "tchaa" COMMA "tchou" });
+ kak_assert(res == WordDB::WordList{ "allo" COMMA "kanaky" COMMA "mutch" COMMA "tchaa" COMMA "tchou" });
kak_assert(word_db.get_word_occurences("tchou") == 3);
kak_assert(word_db.get_word_occurences("allo") == 1);
buffer.erase(buffer.iterator_at({1, 6}), buffer.iterator_at({4, 0}));
res = word_db.find_matching("", prefix_match);
std::sort(res.begin(), res.end());
- kak_assert(res == std::vector<InternedString>{ "allo" COMMA "mutch" COMMA "tchou" });
+ kak_assert(res == WordDB::WordList{ "allo" COMMA "mutch" COMMA "tchou" });
buffer.insert(buffer.iterator_at({1, 0}), "re");
res = word_db.find_matching("", subsequence_match);
std::sort(res.begin(), res.end());
- kak_assert(res == std::vector<InternedString>{ "allo" COMMA "mutch" COMMA "retchou" COMMA "tchou" });
+ kak_assert(res == WordDB::WordList{ "allo" COMMA "mutch" COMMA "retchou" COMMA "tchou" });
}
void test_utf8()
diff --git a/src/word_db.cc b/src/word_db.cc
index cf79afdc..a2dce1cf 100644
--- a/src/word_db.cc
+++ b/src/word_db.cc
@@ -28,7 +28,7 @@ UsedLetters used_letters(StringView str)
static WordDB::WordList get_words(const InternedString& content)
{
- std::vector<InternedString> res;
+ WordDB::WordList res;
using Iterator = utf8::iterator<const char*, utf8::InvalidPolicy::Pass>;
const char* word_start = content.begin();
bool in_word = false;
diff --git a/src/word_db.hh b/src/word_db.hh
index 50496113..e50e0edc 100644
--- a/src/word_db.hh
+++ b/src/word_db.hh
@@ -22,13 +22,13 @@ public:
WordDB(const WordDB&) = delete;
WordDB(WordDB&&) = default;
- using WordList = std::vector<InternedString>;
+ using WordList = Vector<InternedString, MemoryDomain::WordDB>;
template<typename MatchFunc>
WordList find_matching(StringView str, MatchFunc match)
{
update_db();
const UsedLetters letters = used_letters(str);
- std::vector<InternedString> res;
+ WordList res;
for (auto&& word : m_words)
{
if ((letters & word.second.letters) == letters and