Use emplace_back for CString

This commit is contained in:
Robert Müller 2022-05-24 21:18:56 +02:00 committed by heinrich5991
parent bea74f3d4f
commit d0b5d096f5
2 changed files with 7 additions and 5 deletions

View file

@ -37,11 +37,7 @@ CLocalizationDatabase::CLocalizationDatabase()
void CLocalizationDatabase::AddString(const char *pOrgStr, const char *pNewStr, const char *pContext)
{
CString s;
s.m_Hash = str_quickhash(pOrgStr);
s.m_ContextHash = str_quickhash(pContext);
s.m_pReplacement = m_StringsHeap.StoreString(*pNewStr ? pNewStr : pOrgStr);
m_Strings.push_back(s);
m_Strings.emplace_back(str_quickhash(pOrgStr), str_quickhash(pContext), m_StringsHeap.StoreString(*pNewStr ? pNewStr : pOrgStr));
}
bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, IConsole *pConsole)

View file

@ -16,6 +16,12 @@ class CLocalizationDatabase
unsigned m_ContextHash;
const char *m_pReplacement;
CString() {}
CString(unsigned Hash, unsigned ContextHash, const char *pReplacement) :
m_Hash(Hash), m_ContextHash(ContextHash), m_pReplacement(pReplacement)
{
}
bool operator<(const CString &Other) const { return m_Hash < Other.m_Hash || (m_Hash == Other.m_Hash && m_ContextHash < Other.m_ContextHash); }
bool operator<=(const CString &Other) const { return m_Hash < Other.m_Hash || (m_Hash == Other.m_Hash && m_ContextHash <= Other.m_ContextHash); }
bool operator==(const CString &Other) const { return m_Hash == Other.m_Hash && m_ContextHash == Other.m_ContextHash; }