Codechange: Use GetVisibleRangeIterators()
in more places. (#12190)
This replaces more first/last index calculation, along with indexed array/vector access, with iterator access instead.
This commit is contained in:
@@ -652,11 +652,8 @@ public:
|
||||
int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2;
|
||||
|
||||
Rect mr = r.WithHeight(this->resize.step_height);
|
||||
auto iter = this->content.begin() + this->vscroll->GetPosition();
|
||||
size_t last = this->vscroll->GetPosition() + this->vscroll->GetCapacity();
|
||||
auto end = (last < this->content.size()) ? this->content.begin() + last : this->content.end();
|
||||
|
||||
for (/**/; iter != end; iter++) {
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->content);
|
||||
for (auto iter = first; iter != last; iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
|
||||
if (ci == this->selected) GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), PC_GREY);
|
||||
|
@@ -527,10 +527,9 @@ public:
|
||||
case WID_NG_MATRIX: {
|
||||
uint16_t y = r.top;
|
||||
|
||||
const int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
|
||||
|
||||
for (int i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||
const NetworkGameList *ngl = this->servers[i];
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->servers);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const NetworkGameList *ngl = *it;
|
||||
this->DrawServerLine(ngl, y, ngl == this->server);
|
||||
y += this->resize.step_height;
|
||||
}
|
||||
|
Reference in New Issue
Block a user