mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add back const with help of mutable shared mutex
This commit is contained in:
parent
5060fd97f0
commit
ae74352fc6
@ -153,7 +153,7 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original
|
||||
return -5;
|
||||
}
|
||||
|
||||
short Mnemonic::getWordIndex(const char* word)
|
||||
short Mnemonic::getWordIndex(const char* word) const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||
DHASH word_hash = DRMakeStringHash(word);
|
||||
|
||||
@ -30,13 +30,13 @@ public:
|
||||
|
||||
int init(void(*fill_words_func)(unsigned char*), unsigned int original_size, unsigned int compressed_size);
|
||||
|
||||
inline const char* getWord(short index) {
|
||||
inline const char* getWord(short index) const {
|
||||
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||
if (index < 2048 && index >= 0) return mWords[index];
|
||||
return nullptr;
|
||||
}
|
||||
short getWordIndex(const char* word);
|
||||
inline bool isWordExist(const std::string& word) {
|
||||
short getWordIndex(const char* word) const;
|
||||
inline bool isWordExist(const std::string& word) const {
|
||||
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||
return getWordIndex(word.data()) != -1;
|
||||
}
|
||||
@ -62,7 +62,7 @@ protected:
|
||||
typedef std::pair<std::string, unsigned short> HashCollideWordEntry;
|
||||
std::map<DHASH, unsigned short> mWordHashIndices;
|
||||
std::map<DHASH, std::map<std::string, unsigned short>> mHashCollisionWords;
|
||||
std::shared_mutex mWorkingMutex;
|
||||
mutable std::shared_mutex mWorkingMutex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user