mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Use emplace_back for CString
This commit is contained in:
parent
bea74f3d4f
commit
d0b5d096f5
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue