Release v0.6.35: reduce resident memory and compact shared dictionaries
This commit is contained in:
+9
-1
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "platform.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
namespace ks
|
||||
@@ -18,23 +19,30 @@ int matchAutoInput(const Run &, const std::wstring &, const std::vector<Layout>
|
||||
bool autoCorrectionAllowed(HWND, const Settings &);
|
||||
class AutoCorrector
|
||||
{
|
||||
friend struct AutoCorrectorRegressionAccess;
|
||||
struct Dictionary
|
||||
{
|
||||
// Front-coded UTF-8 words in independently searchable blocks of 32.
|
||||
// Prefix/suffix lengths share a byte (15 escapes to a full byte length).
|
||||
// Ranks use two bytes; 65535 escapes to a varint for larger custom ranks.
|
||||
std::string bytes;
|
||||
std::vector<uint32_t> offsets;
|
||||
std::string_view word(size_t) const;
|
||||
explicit Dictionary(const std::filesystem::path &);
|
||||
int rank(const std::wstring &) const;
|
||||
};
|
||||
std::map<std::wstring, Dictionary> dictionaries;
|
||||
std::map<std::wstring, std::shared_ptr<const Dictionary>> dictionaries;
|
||||
std::vector<std::wstring> languages;
|
||||
std::set<std::wstring> rejected;
|
||||
|
||||
public:
|
||||
void configure(const std::filesystem::path &, const std::vector<std::wstring> &);
|
||||
// Share immutable dictionary storage, keeping each consumer's undo rejections private.
|
||||
void shareDictionaries(const AutoCorrector &);
|
||||
std::optional<AutoSuggestion> suggest(const std::wstring &, int source, const std::vector<Layout> &,
|
||||
const Settings &) const;
|
||||
void reject(std::wstring word, const Settings & = {});
|
||||
// Referenced dictionary payload, including shared storage (do not sum across consumers).
|
||||
size_t memoryBytes() const;
|
||||
};
|
||||
} // namespace ks
|
||||
|
||||
Reference in New Issue
Block a user