Track some more memory
This commit is contained in:
parent
9adb97ea28
commit
dedb16bc73
|
@ -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] + "'");
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user