mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #14 from lioncash/emplace
General: Use emplace_back's return value where applicable
This commit is contained in:
commit
c32c8d0a91
|
@ -335,8 +335,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));
|
||||||
|
|
|
@ -525,9 +525,7 @@ bool Table::CellView::reset(size_t c, size_t r) {
|
||||||
|
|
||||||
std::vector<Table::ColumnPool>& Table::ensureCellPools(size_t rows, size_t cols, ViewResources& res) {
|
std::vector<Table::ColumnPool>& Table::ensureCellPools(size_t rows, size_t cols, ViewResources& res) {
|
||||||
if (m_cellPools.size() < cols) {
|
if (m_cellPools.size() < cols) {
|
||||||
m_cellPools.reserve(cols);
|
m_cellPools.resize(cols);
|
||||||
for (size_t i = m_cellPools.size(); i < cols; ++i)
|
|
||||||
m_cellPools.emplace_back();
|
|
||||||
m_ensuredRows = 0;
|
m_ensuredRows = 0;
|
||||||
}
|
}
|
||||||
if (m_ensuredRows < rows) {
|
if (m_ensuredRows < rows) {
|
||||||
|
@ -569,9 +567,7 @@ void Table::_updateData() {
|
||||||
if (newViewChildren) {
|
if (newViewChildren) {
|
||||||
m_headerViews.clear();
|
m_headerViews.clear();
|
||||||
m_cellPools.clear();
|
m_cellPools.clear();
|
||||||
m_headerViews.reserve(m_columns);
|
m_headerViews.resize(m_columns);
|
||||||
for (size_t c = 0; c < m_columns; ++c)
|
|
||||||
m_headerViews.emplace_back();
|
|
||||||
m_ensuredRows = 0;
|
m_ensuredRows = 0;
|
||||||
}
|
}
|
||||||
ensureCellPools(m_rows, m_columns, res);
|
ensureCellPools(m_rows, m_columns, res);
|
||||||
|
|
|
@ -20,11 +20,9 @@ void Toolbar::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const ITh
|
||||||
Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned units)
|
Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned units)
|
||||||
: View(res, parentView)
|
: View(res, parentView)
|
||||||
, m_units(units)
|
, m_units(units)
|
||||||
|
, m_children(units)
|
||||||
, m_nomGauge(res.pixelFactor() * SPECTER_TOOLBAR_GAUGE * units)
|
, m_nomGauge(res.pixelFactor() * SPECTER_TOOLBAR_GAUGE * units)
|
||||||
, m_padding(res.pixelFactor() * TOOLBAR_PADDING) {
|
, m_padding(res.pixelFactor() * TOOLBAR_PADDING) {
|
||||||
m_children.reserve(units);
|
|
||||||
for (unsigned u = 0; u < units; ++u)
|
|
||||||
m_children.emplace_back();
|
|
||||||
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool {
|
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool {
|
||||||
buildResources(ctx, res);
|
buildResources(ctx, res);
|
||||||
m_tbBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
|
m_tbBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
|
||||||
|
@ -115,11 +113,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