mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
speed up build time
This commit is contained in:
parent
cc6b885be3
commit
8fe5b1cc09
@ -132,11 +132,11 @@ std::string KeyPair::getPubkeyHex()
|
||||
return std::string(hexString);
|
||||
}
|
||||
|
||||
std::string KeyPair::getHex(const unsigned char* data, size_t size)
|
||||
std::string KeyPair::getHex(const unsigned char* data, Poco::UInt32 size)
|
||||
{
|
||||
auto mm = MemoryManager::getInstance();
|
||||
|
||||
size_t hexSize = size * 2 + 1;
|
||||
Poco::UInt32 hexSize = size * 2 + 1;
|
||||
auto hexMem = mm->getFreeMemory(hexSize);
|
||||
//char* hexString = (char*)malloc(hexSize);
|
||||
memset(*hexMem, 0, hexSize);
|
||||
|
||||
@ -24,7 +24,7 @@ public:
|
||||
bool generateFromPassphrase(const char* passphrase, Mnemonic* word_source);
|
||||
std::string getPubkeyHex();
|
||||
bool savePrivKey(int userId);
|
||||
static std::string getHex(const unsigned char* data, size_t size);
|
||||
static std::string getHex(const unsigned char* data, Poco::UInt32 size);
|
||||
|
||||
inline const unsigned char* getPublicKey() const { return mSodiumPublic; }
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
Mnemonic::Mnemonic()
|
||||
{
|
||||
memset(mWords, 0, 2048);
|
||||
mWordHashIndices.resize(2048);
|
||||
// mWordHashIndices.resize(2048);
|
||||
}
|
||||
|
||||
Mnemonic::~Mnemonic()
|
||||
@ -21,7 +21,7 @@ Mnemonic::~Mnemonic()
|
||||
}
|
||||
}
|
||||
memset(mWords, 0, 2048);
|
||||
mWordHashIndices.clear(true);
|
||||
mWordHashIndices.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original
|
||||
|
||||
//printf("c[Mnemonic::%s] uncompressing success\n", __FUNCTION__);
|
||||
// fill words in array and hashList
|
||||
int cursor = 0;
|
||||
unsigned short cursor = 0;
|
||||
u32 word_begin = 0, word_end = 0;
|
||||
|
||||
for (unsigned int i = 0; i < original_size; i++) {
|
||||
@ -87,7 +87,8 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original
|
||||
//printf("word (%d): %s\n", cursor, bu);
|
||||
|
||||
DHASH word_hash = DRMakeStringHash(mWords[cursor]);
|
||||
mWordHashIndices.addByHash(word_hash, (void*)cursor);
|
||||
//mWordHashIndices.addByHash(word_hash, (void*)cursor);
|
||||
mWordHashIndices.insert(WordHashEntry(word_hash, cursor));
|
||||
|
||||
word_begin = i + 1;
|
||||
cursor++;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include "../lib/DRHashList.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#define PHRASE_WORD_COUNT 24
|
||||
|
||||
@ -26,12 +27,14 @@ public:
|
||||
int init(void(*fill_words_func)(unsigned char*), unsigned int original_size, unsigned int compressed_size);
|
||||
|
||||
inline const char* getWord(unsigned int index) { if (index < 2048) return mWords[index]; return nullptr; }
|
||||
inline unsigned long getWordIndex(const char* word) { DHASH word_hash = DRMakeStringHash(word); return (long)mWordHashIndices.findByHash(word_hash); }
|
||||
inline bool isWordExist(const std::string& word) { DHASH word_hash = DRMakeStringHash(word.data()); return mWordHashIndices.itemExists(word_hash); }
|
||||
inline unsigned short getWordIndex(const char* word) { DHASH word_hash = DRMakeStringHash(word); return mWordHashIndices.find(word_hash)->second; }
|
||||
inline bool isWordExist(const std::string& word) { DHASH word_hash = DRMakeStringHash(word.data()); return mWordHashIndices.find(word_hash) != mWordHashIndices.end(); }
|
||||
|
||||
protected:
|
||||
char* mWords[2048];
|
||||
DRHashList mWordHashIndices;
|
||||
//DRHashList mWordHashIndices;
|
||||
typedef std::pair<DHASH, unsigned short> WordHashEntry;
|
||||
std::map<DHASH, unsigned short> mWordHashIndices;
|
||||
};
|
||||
|
||||
#endif //DR_MNEMONIC_H
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include <spirit_po/spirit_po.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
LanguageCatalog::LanguageCatalog(Languages lang)
|
||||
@ -52,6 +54,72 @@ void LanguageCatalog::release()
|
||||
}
|
||||
|
||||
|
||||
void LanguageCatalog::duplicate()
|
||||
{
|
||||
lock();
|
||||
mReferenceCount++;
|
||||
unlock();
|
||||
}
|
||||
|
||||
const char * LanguageCatalog::gettext(const char * msgid)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->gettext(msgid);
|
||||
}
|
||||
|
||||
const char * LanguageCatalog::ngettext(const char * msgid, const char * msgid_plural, spirit_po::uint plural)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->ngettext(msgid, msgid_plural, plural);
|
||||
}
|
||||
const char * LanguageCatalog::pgettext(const char * msgctxt, const char * msgid)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->pgettext(msgctxt, msgid);
|
||||
}
|
||||
inline const char * LanguageCatalog::npgettext(const char * msgctxt, const char * msgid, const char * msgid_plural, spirit_po::uint plural)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->npgettext(msgctxt, msgid, msgid_plural, plural);
|
||||
}
|
||||
|
||||
std::string LanguageCatalog::gettext_str(const std::string & msgid)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->gettext_str(msgid);
|
||||
}
|
||||
std::string LanguageCatalog::ngettext_str(const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->ngettext_str(msgid, msgid_plural, plural);
|
||||
}
|
||||
std::string LanguageCatalog::pgettext_str(const std::string & msgctxt, const std::string & msgid)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->pgettext_str(msgctxt, msgid);
|
||||
}
|
||||
std::string LanguageCatalog::npgettext_str(const std::string & msgctxt, const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural)
|
||||
{
|
||||
if (!mCatalog) {
|
||||
return msgid;
|
||||
}
|
||||
return ((spirit_po::default_catalog*)(mCatalog))->npgettext_str(msgctxt, msgid, msgid_plural, plural);
|
||||
}
|
||||
|
||||
// ******************************************************
|
||||
|
||||
LanguageManager* LanguageManager::getInstance()
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include "Poco/Logger.h"
|
||||
|
||||
#include "../lib/MultithreadContainer.h"
|
||||
#include <spirit_po/spirit_po.hpp>
|
||||
//#include <spirit_po/spirit_po.hpp>
|
||||
#include <list>
|
||||
|
||||
|
||||
@ -25,46 +25,42 @@ enum Languages {
|
||||
LANG_NULL
|
||||
};
|
||||
|
||||
//spirit_po::default_catalog
|
||||
namespace spirit_po {
|
||||
//class default_catalog;
|
||||
//using default_catalog = catalog<>;
|
||||
typedef unsigned int uint;
|
||||
|
||||
}
|
||||
|
||||
class LanguageCatalog : protected UniLib::lib::MultithreadContainer
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
LanguageCatalog(Languages lang);
|
||||
~LanguageCatalog();
|
||||
|
||||
// for poco auto ptr
|
||||
void duplicate() { lock(); mReferenceCount++; unlock(); };
|
||||
void duplicate();
|
||||
void release();
|
||||
|
||||
// catalog overload api
|
||||
|
||||
inline const char * gettext(const char * msgid) { if (!mCatalog) return msgid; return mCatalog->gettext(msgid); }
|
||||
inline const char * ngettext(const char * msgid, const char * msgid_plural, spirit_po::uint plural) {
|
||||
return mCatalog->ngettext(msgid, msgid_plural, plural);
|
||||
}
|
||||
inline const char * pgettext(const char * msgctxt, const char * msgid) {
|
||||
return mCatalog->pgettext(msgctxt, msgid);
|
||||
}
|
||||
inline const char * npgettext(const char * msgctxt, const char * msgid, const char * msgid_plural, spirit_po::uint plural) {
|
||||
return mCatalog->npgettext(msgctxt, msgid, msgid_plural, plural);
|
||||
}
|
||||
const char * LanguageCatalog::gettext(const char * msgid);
|
||||
const char * LanguageCatalog::ngettext(const char * msgid, const char * msgid_plural, spirit_po::uint plural);
|
||||
const char * LanguageCatalog::pgettext(const char * msgctxt, const char * msgid);
|
||||
const char * LanguageCatalog::npgettext(const char * msgctxt, const char * msgid, const char * msgid_plural, spirit_po::uint plural);
|
||||
|
||||
inline std::string gettext_str(const std::string & msgid) { if (!mCatalog) return msgid; return mCatalog->gettext_str(msgid); }
|
||||
inline std::string ngettext_str(const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural) {
|
||||
return mCatalog->ngettext_str(msgid, msgid_plural, plural);
|
||||
}
|
||||
inline std::string pgettext_str(const std::string & msgctxt, const std::string & msgid) {
|
||||
return mCatalog->pgettext_str(msgctxt, msgid);
|
||||
}
|
||||
inline std::string npgettext_str(const std::string & msgctxt, const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural) {
|
||||
return mCatalog->npgettext_str(msgctxt, msgid, msgid_plural, plural);
|
||||
}
|
||||
std::string LanguageCatalog::gettext_str(const std::string & msgid);
|
||||
std::string LanguageCatalog::ngettext_str(const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural);
|
||||
std::string LanguageCatalog::pgettext_str(const std::string & msgctxt, const std::string & msgid);
|
||||
std::string LanguageCatalog::npgettext_str(const std::string & msgctxt, const std::string & msgid, const std::string & msgid_plural, spirit_po::uint plural);
|
||||
|
||||
inline Languages getLanguage() { return mThisLanguage; }
|
||||
|
||||
protected:
|
||||
int mReferenceCount;
|
||||
spirit_po::default_catalog* mCatalog;
|
||||
void* mCatalog;
|
||||
Languages mThisLanguage;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user