mirror of https://github.com/AxioDL/metaforce.git
CStringTable: Use std::array instead of std::vector
Gets rid of a static constructor, as well as a few heap allocations
This commit is contained in:
parent
484a6b0cdf
commit
e23dfbd8db
|
@ -1,11 +1,17 @@
|
||||||
#include "CStringTable.hpp"
|
#include "Runtime/GuiSys/CStringTable.hpp"
|
||||||
#include "CToken.hpp"
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "Runtime/CToken.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
const std::vector<FourCC> CStringTable::skLanguages = {FOURCC('ENGL'), FOURCC('FREN'), FOURCC('GERM'), FOURCC('SPAN'),
|
namespace {
|
||||||
FOURCC('ITAL'), FOURCC('DUTC'), FOURCC('JAPN')};
|
constexpr std::array languages{
|
||||||
|
FOURCC('ENGL'), FOURCC('FREN'), FOURCC('GERM'), FOURCC('SPAN'), FOURCC('ITAL'), FOURCC('DUTC'), FOURCC('JAPN'),
|
||||||
|
};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
FourCC CStringTable::mCurrentLanguage = CStringTable::skLanguages[0];
|
FourCC CStringTable::mCurrentLanguage = languages[0];
|
||||||
|
|
||||||
CStringTable::CStringTable(CInputStream& in) { LoadStringTable(in); }
|
CStringTable::CStringTable(CInputStream& in) { LoadStringTable(in); }
|
||||||
|
|
||||||
|
@ -64,7 +70,7 @@ const char16_t* CStringTable::GetString(s32 str) const {
|
||||||
return reinterpret_cast<char16_t*>(x4_data.get() + off);
|
return reinterpret_cast<char16_t*>(x4_data.get() + off);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStringTable::SetLanguage(s32 lang) { mCurrentLanguage = skLanguages[lang]; }
|
void CStringTable::SetLanguage(s32 lang) { mCurrentLanguage = languages[lang]; }
|
||||||
|
|
||||||
CFactoryFnReturn FStringTableFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&,
|
CFactoryFnReturn FStringTableFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&,
|
||||||
CObjectReference* selfRef) {
|
CObjectReference* selfRef) {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
class CStringTable {
|
class CStringTable {
|
||||||
static const std::vector<FourCC> skLanguages;
|
|
||||||
static FourCC mCurrentLanguage;
|
static FourCC mCurrentLanguage;
|
||||||
u32 x0_stringCount = 0;
|
u32 x0_stringCount = 0;
|
||||||
std::unique_ptr<u8[]> x4_data = 0;
|
std::unique_ptr<u8[]> x4_data = 0;
|
||||||
|
|
Loading…
Reference in New Issue