summaryrefslogtreecommitdiff
path: root/src/gfx_layout.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-02-17 11:20:52 +0000
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commitab711e6942757d775c08c31a6c32d488feba1dba (patch)
treed102dc6d0e6b9c33e7205b63e3360ebd720a3ebb /src/gfx_layout.cpp
parent297fd3dda3abe353ebe2fe77c67b011e24d403bc (diff)
downloadopenttd-ab711e6942757d775c08c31a6c32d488feba1dba.tar.xz
Codechange: Replaced SmallVector::[Begin|End]() with std alternatives
Diffstat (limited to 'src/gfx_layout.cpp')
-rw-r--r--src/gfx_layout.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index ee0ba1533..6d4759cfb 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -196,13 +196,13 @@ public:
/* ICU's ParagraphLayout cannot handle empty strings, so fake one. */
buff[0] = ' ';
length = 1;
- fontMapping.End()[-1].first++;
+ fontMapping.back().first++;
}
/* Fill ICU's FontRuns with the right data. */
icu::FontRuns runs(fontMapping.size());
- for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) {
- runs.add(iter->second, iter->first);
+ for (auto &pair : fontMapping) {
+ runs.add(pair.second, pair.first);
}
LEErrorCode status = LE_NO_ERROR;
@@ -419,8 +419,8 @@ int FallbackParagraphLayout::FallbackVisualRun::GetLeading() const
int FallbackParagraphLayout::FallbackLine::GetLeading() const
{
int leading = 0;
- for (const FallbackVisualRun * const *run = this->Begin(); run != this->End(); run++) {
- leading = max(leading, (*run)->GetLeading());
+ for (const FallbackVisualRun * const &run : *this) {
+ leading = max(leading, run->GetLeading());
}
return leading;
@@ -498,12 +498,12 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
if (*this->buffer == '\0') {
/* Only a newline. */
this->buffer = NULL;
- l->push_back(new FallbackVisualRun(this->runs.Begin()->second, this->buffer, 0, 0));
+ l->push_back(new FallbackVisualRun(this->runs.front().second, this->buffer, 0, 0));
return l;
}
int offset = this->buffer - this->buffer_begin;
- FontMap::iterator iter = this->runs.Begin();
+ FontMap::iterator iter = this->runs.data();
while (iter->first <= offset) {
iter++;
assert(iter != this->runs.End());
@@ -733,9 +733,9 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
Dimension Layouter::GetBounds()
{
Dimension d = { 0, 0 };
- for (const ParagraphLayouter::Line **l = this->Begin(); l != this->End(); l++) {
- d.width = max<uint>(d.width, (*l)->GetWidth());
- d.height += (*l)->GetLeading();
+ for (const ParagraphLayouter::Line *l : *this) {
+ d.width = max<uint>(d.width, l->GetWidth());
+ d.height += l->GetLeading();
}
return d;
}
@@ -757,12 +757,12 @@ Point Layouter::GetCharPosition(const char *ch) const
size_t len = Utf8Decode(&c, str);
if (c == '\0' || c == '\n') break;
str += len;
- index += (*this->Begin())->GetInternalCharLength(c);
+ index += this->front()->GetInternalCharLength(c);
}
if (str == ch) {
/* Valid character. */
- const ParagraphLayouter::Line *line = *this->Begin();
+ const ParagraphLayouter::Line *line = this->front();
/* Pointer to the end-of-string/line marker? Return total line width. */
if (*ch == '\0' || *ch == '\n') {
@@ -795,7 +795,7 @@ Point Layouter::GetCharPosition(const char *ch) const
*/
const char *Layouter::GetCharAtPosition(int x) const
{
- const ParagraphLayouter::Line *line = *this->Begin();
+ const ParagraphLayouter::Line *line = this->front();
for (int run_index = 0; run_index < line->CountRuns(); run_index++) {
const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index);
@@ -844,8 +844,8 @@ Font *Layouter::GetFont(FontSize size, TextColour colour)
*/
void Layouter::ResetFontCache(FontSize size)
{
- for (FontColourMap::iterator it = fonts[size].Begin(); it != fonts[size].End(); ++it) {
- delete it->second;
+ for (auto &pair : fonts[size]) {
+ delete pair.second;
}
fonts[size].clear();