mirror of https://github.com/AxioDL/metaforce.git
General: Use emplace_back's return value where applicable
emplace_back() returns a reference to the added element, so we can use that instead of querying right after the emplacement.
This commit is contained in:
parent
8ff9e028c7
commit
fa56ba5db6
|
@ -334,8 +334,7 @@ void FileBrowser::FileListingDataBind::updateListing(const hecl::DirectoryEnumer
|
||||||
m_entries.reserve(dEnum.size());
|
m_entries.reserve(dEnum.size());
|
||||||
|
|
||||||
for (const hecl::DirectoryEnumerator::Entry& d : dEnum) {
|
for (const hecl::DirectoryEnumerator::Entry& d : dEnum) {
|
||||||
m_entries.emplace_back();
|
Entry& ent = m_entries.emplace_back();
|
||||||
Entry& ent = m_entries.back();
|
|
||||||
ent.m_path = d.m_path;
|
ent.m_path = d.m_path;
|
||||||
hecl::SystemUTF8Conv nameUtf8(d.m_name);
|
hecl::SystemUTF8Conv nameUtf8(d.m_name);
|
||||||
ent.m_name = nameUtf8.str();
|
ent.m_name = nameUtf8.str();
|
||||||
|
|
|
@ -307,13 +307,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags);
|
FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags);
|
||||||
FT_UInt width, height;
|
FT_UInt width, height;
|
||||||
GridFitGlyph(face->glyph, width, height);
|
GridFitGlyph(face->glyph, width, height);
|
||||||
m_glyphLookup[charcode] = m_glyphs.size();
|
|
||||||
m_glyphs.emplace_back();
|
|
||||||
Glyph& g = m_glyphs.back();
|
|
||||||
|
|
||||||
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
||||||
totalHeight += curLineHeight + 1;
|
totalHeight += curLineHeight + 1;
|
||||||
curLineHeight = 0;
|
curLineHeight = 0;
|
||||||
|
@ -328,6 +325,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
curLineWidth = 1;
|
curLineWidth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_glyphLookup.insert_or_assign(charcode, m_glyphs.size());
|
||||||
|
Glyph& g = m_glyphs.emplace_back();
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
g.m_glyphIdx = gindex;
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = m_fullTexmapLayers;
|
g.m_layerIdx = m_fullTexmapLayers;
|
||||||
|
@ -369,13 +368,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags);
|
FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags);
|
||||||
FT_UInt width, height;
|
FT_UInt width, height;
|
||||||
GridFitGlyph(face->glyph, width, height);
|
GridFitGlyph(face->glyph, width, height);
|
||||||
m_glyphLookup[charcode] = m_glyphs.size();
|
|
||||||
m_glyphs.emplace_back();
|
|
||||||
Glyph& g = m_glyphs.back();
|
|
||||||
|
|
||||||
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
||||||
totalHeight += curLineHeight + 1;
|
totalHeight += curLineHeight + 1;
|
||||||
curLineHeight = 0;
|
curLineHeight = 0;
|
||||||
|
@ -390,6 +386,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
curLineWidth = 1;
|
curLineWidth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_glyphLookup.insert_or_assign(charcode, m_glyphs.size());
|
||||||
|
Glyph& g = m_glyphs.emplace_back();
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
g.m_glyphIdx = gindex;
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = m_fullTexmapLayers;
|
g.m_layerIdx = m_fullTexmapLayers;
|
||||||
|
@ -468,13 +466,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Load_Glyph(face, gindex, baseFlags);
|
FT_Load_Glyph(face, gindex, baseFlags);
|
||||||
FT_UInt width, height;
|
FT_UInt width, height;
|
||||||
GridFitGlyph(face->glyph, width, height);
|
GridFitGlyph(face->glyph, width, height);
|
||||||
m_glyphLookup[charcode] = m_glyphs.size();
|
|
||||||
m_glyphs.emplace_back();
|
|
||||||
Glyph& g = m_glyphs.back();
|
|
||||||
|
|
||||||
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
||||||
totalHeight += curLineHeight + 1;
|
totalHeight += curLineHeight + 1;
|
||||||
curLineHeight = 0;
|
curLineHeight = 0;
|
||||||
|
@ -489,6 +484,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
curLineWidth = 1;
|
curLineWidth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_glyphLookup.insert_or_assign(charcode, m_glyphs.size());
|
||||||
|
Glyph& g = m_glyphs.emplace_back();
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
g.m_glyphIdx = gindex;
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = m_fullTexmapLayers;
|
g.m_layerIdx = m_fullTexmapLayers;
|
||||||
|
@ -530,13 +527,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
charcode = FT_Get_Next_Char(face, charcode, &gindex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Load_Glyph(face, gindex, baseFlags);
|
FT_Load_Glyph(face, gindex, baseFlags);
|
||||||
FT_UInt width, height;
|
FT_UInt width, height;
|
||||||
GridFitGlyph(face->glyph, width, height);
|
GridFitGlyph(face->glyph, width, height);
|
||||||
m_glyphLookup[charcode] = m_glyphs.size();
|
|
||||||
m_glyphs.emplace_back();
|
|
||||||
Glyph& g = m_glyphs.back();
|
|
||||||
|
|
||||||
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
if (curLineWidth + width + 1 > TEXMAP_DIM) {
|
||||||
totalHeight += curLineHeight + 1;
|
totalHeight += curLineHeight + 1;
|
||||||
curLineHeight = 0;
|
curLineHeight = 0;
|
||||||
|
@ -551,6 +545,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil
|
||||||
curLineWidth = 1;
|
curLineWidth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_glyphLookup.insert_or_assign(charcode, m_glyphs.size());
|
||||||
|
Glyph& g = m_glyphs.emplace_back();
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
g.m_glyphIdx = gindex;
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = m_fullTexmapLayers;
|
g.m_layerIdx = m_fullTexmapLayers;
|
||||||
|
|
|
@ -55,9 +55,7 @@ void Menu::reset(IMenuNode* rootNode) {
|
||||||
for (size_t i = 0; i < subCount; ++i) {
|
for (size_t i = 0; i < subCount; ++i) {
|
||||||
IMenuNode* node = rootNode->subNode(i);
|
IMenuNode* node = rootNode->subNode(i);
|
||||||
const std::string* nodeText = node->text();
|
const std::string* nodeText = node->text();
|
||||||
|
ViewChild<std::unique_ptr<ItemView>>& item = m_items.emplace_back();
|
||||||
m_items.emplace_back();
|
|
||||||
ViewChild<std::unique_ptr<ItemView>>& item = m_items.back();
|
|
||||||
|
|
||||||
if (nodeText) {
|
if (nodeText) {
|
||||||
item.m_view.reset(new ItemView(res, *this, *nodeText, i, node));
|
item.m_view.reset(new ItemView(res, *this, *nodeText, i, node));
|
||||||
|
|
|
@ -115,11 +115,13 @@ void Toolbar::setVerticalVerts(int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toolbar::push_back(View* v, unsigned unit) {
|
void Toolbar::push_back(View* v, unsigned unit) {
|
||||||
if (unit >= m_units)
|
if (unit >= m_units) {
|
||||||
Log.report(logvisor::Fatal, fmt("unit {} out of range {}"), unit, m_units);
|
Log.report(logvisor::Fatal, fmt("unit {} out of range {}"), unit, m_units);
|
||||||
std::vector<ViewChild<View*>>& u = m_children[unit];
|
}
|
||||||
u.emplace_back();
|
|
||||||
u.back().m_view = v;
|
std::vector<ViewChild<View*>>& children = m_children[unit];
|
||||||
|
auto& child = children.emplace_back();
|
||||||
|
child.m_view = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
||||||
|
|
Loading…
Reference in New Issue