Appended references to const auto type in loop to prevent copying.

This commit is contained in:
23rd 2021-09-08 14:00:36 +03:00
parent f4cf3094c2
commit beb09445d1
6 changed files with 6 additions and 6 deletions

View file

@ -866,7 +866,7 @@ QImage GenerateLinearGradient(
auto stops = QGradientStops(); auto stops = QGradientStops();
const auto step = 1. / (colors.size() - 1); const auto step = 1. / (colors.size() - 1);
auto point = 0.; auto point = 0.;
for (const auto color : colors) { for (const auto &color : colors) {
stops.append({ point, color }); stops.append({ point, color });
point += step; point += step;
} }

View file

@ -245,7 +245,7 @@ void BoxContent::paintEvent(QPaintEvent *e) {
if (testAttribute(Qt::WA_OpaquePaintEvent)) { if (testAttribute(Qt::WA_OpaquePaintEvent)) {
const auto &color = getDelegate()->style().bg; const auto &color = getDelegate()->style().bg;
for (const auto rect : e->region()) { for (const auto &rect : e->region()) {
p.fillRect(rect, color); p.fillRect(rect, color);
} }
} }

View file

@ -126,7 +126,7 @@ void BoxLayerWidget::paintEvent(QPaintEvent *e) {
} }
auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
if (!other.isEmpty()) { if (!other.isEmpty()) {
for (const auto rect : other) { for (const auto &rect : other) {
p.fillRect(rect, st().bg); p.fillRect(rect, st().bg);
} }
} }

View file

@ -281,7 +281,7 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) {
// in the transparent special layer cache corners after filling special layer // in the transparent special layer cache corners after filling special layer
// rect above its cache with alpha_current opacity. // rect above its cache with alpha_current opacity.
const auto region = QRegion(bg) - specialLayerBox; const auto region = QRegion(bg) - specialLayerBox;
for (const auto rect : region) { for (const auto &rect : region) {
p.fillRect(rect, st::layerBg); p.fillRect(rect, st::layerBg);
} }
p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF()))); p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF())));

View file

@ -18,7 +18,7 @@ namespace {
auto result = TextWithEntities(); auto result = TextWithEntities();
result.text.reserve(text.size()); result.text.reserve(text.size());
auto afterAmpersand = false; auto afterAmpersand = false;
for (const auto ch : text) { for (const auto &ch : text) {
if (afterAmpersand) { if (afterAmpersand) {
afterAmpersand = false; afterAmpersand = false;
if (ch == '&') { if (ch == '&') {

View file

@ -37,7 +37,7 @@ PopupMenu::PopupMenu(QWidget *parent, QMenu *menu, const style::PopupMenu &st)
, _menu(this, menu, _st.menu) { , _menu(this, menu, _st.menu) {
init(); init();
for (const auto action : actions()) { for (const auto &action : actions()) {
if (const auto submenu = action->menu()) { if (const auto submenu = action->menu()) {
_submenus.emplace( _submenus.emplace(
action, action,