Replace post-increment with pre-increment

And post-decrement with pre-decrement.
This commit is contained in:
Chocobo1 2018-05-31 01:06:28 +08:00
parent 40330c4606
commit 5ddbf9bba9
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
16 changed files with 58 additions and 58 deletions

View file

@ -67,7 +67,7 @@ namespace
// ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have large
// Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
for (int i = 0; i < key.length(); i++) {
for (int i = 0; i < key.length(); ++i) {
innerPadding[i] = innerPadding[i] ^ key.at(i); // XOR operation between every byte in key and innerpadding, of key length
outerPadding[i] = outerPadding[i] ^ key.at(i); // XOR operation between every byte in key and outerpadding, of key length
}

View file

@ -867,7 +867,7 @@ namespace
LONG res = ::RegQueryInfoKeyW(handle, NULL, NULL, NULL, &cSubKeys, &cMaxSubKeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
if (res == ERROR_SUCCESS) {
cMaxSubKeyLen++; // For null character
++cMaxSubKeyLen; // For null character
LPWSTR lpName = new WCHAR[cMaxSubKeyLen];
DWORD cName;

View file

@ -172,7 +172,7 @@ bool Utils::String::slowEquals(const QByteArray &a, const QByteArray &b)
int lengthB = b.length();
int diff = lengthA ^ lengthB;
for (int i = 0; (i < lengthA) && (i < lengthB); i++)
for (int i = 0; (i < lengthA) && (i < lengthB); ++i)
diff |= a[i] ^ b[i];
return (diff == 0);

View file

@ -102,7 +102,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
hideColumn(PeerListDelegate::COUNTRY);
// Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) {
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
if (!isColumnHidden(i)) {
atLeastOne = true;
break;
@ -113,7 +113,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
// To also mitigate the above issue, we have to resize each column when
// its size is 0, because explicitly 'showing' the column isn't enough
// in the above scenario.
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++)
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
resizeColumnToContents(i);
// Context menu
@ -168,9 +168,9 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &)
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) {
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
if (!isColumnHidden(i))
visibleCols++;
++visibleCols;
if (visibleCols > 1)
break;

View file

@ -424,7 +424,7 @@ void PluginSelectDlg::checkForUpdatesFinished(const QHash<QString, PluginVersion
for (auto i = updateInfo.cbegin(); i != updateInfo.cend(); ++i) {
startAsyncOp();
m_pendingUpdates++;
++m_pendingUpdates;
m_pluginManager->updatePlugin(i.key());
}
}

View file

@ -104,7 +104,7 @@ SearchTab::SearchTab(SearchHandler *searchHandler, QWidget *parent)
// Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; i++) {
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i) {
if (!m_ui->resultsBrowser->isColumnHidden(i)) {
atLeastOne = true;
break;
@ -115,7 +115,7 @@ SearchTab::SearchTab(SearchHandler *searchHandler, QWidget *parent)
// To also mitigate the above issue, we have to resize each column when
// its size is 0, because explicitly 'showing' the column isn't enough
// in the above scenario.
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; i++)
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i)
if ((m_ui->resultsBrowser->columnWidth(i) <= 0) && !m_ui->resultsBrowser->isColumnHidden(i))
m_ui->resultsBrowser->resizeColumnToContents(i);
@ -375,9 +375,9 @@ void SearchTab::displayToggleColumnsMenu(const QPoint&)
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; i++) {
for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i) {
if (!m_ui->resultsBrowser->isColumnHidden(i))
visibleCols++;
++visibleCols;
if (visibleCols > 1)
break;

View file

@ -131,7 +131,7 @@ bool TorrentContentFilterModel::hasFiltered(const QModelIndex &folder) const
QString name = folder.data().toString();
if (name.contains(filterRegExp()))
return true;
for (int child = 0; child < m_model->rowCount(folder); child++) {
for (int child = 0; child < m_model->rowCount(folder); ++child) {
QModelIndex childIndex = m_model->index(child, 0, folder);
if (m_model->hasChildren(childIndex)) {
if (hasFiltered(childIndex))

View file

@ -260,7 +260,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
//Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (unsigned int i = 0; i<TorrentModel::NB_COLUMNS; i++) {
for (unsigned int i = 0; i < TorrentModel::NB_COLUMNS; ++i) {
if (!isColumnHidden(i)) {
atLeastOne = true;
break;
@ -272,7 +272,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
//When adding/removing columns between versions some may
//end up being size 0 when the new version is launched with
//a conf file from the previous version.
for (unsigned int i = 0; i<TorrentModel::NB_COLUMNS; i++)
for (unsigned int i = 0; i < TorrentModel::NB_COLUMNS; ++i)
if ((columnWidth(i) <= 0) && (!isColumnHidden(i)))
resizeColumnToContents(i);
@ -713,9 +713,9 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i = 0; i<TorrentModel::NB_COLUMNS; i++) {
for (unsigned int i = 0; i < TorrentModel::NB_COLUMNS; ++i) {
if (!isColumnHidden(i))
visibleCols++;
++visibleCols;
if (visibleCols > 1)
break;

View file

@ -559,7 +559,7 @@
getWatchedFolders = function() {
var nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
var folders = new Hash();
for (var i = 0; i < nb_folders; i++) {
for (var i = 0; i < nb_folders; ++i) {
var fpath = $('text_watch_' + i).getProperty('value').trim();
if (fpath.length > 0) {
var other;

View file

@ -58,7 +58,7 @@ loadSelectedCategory();
function genHash(string) {
var hash = 0;
for (var i = 0; i < string.length; i++) {
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
hash = (c + hash * 31) | 0;
}

View file

@ -88,7 +88,7 @@ var ContextMenu = new Class({
// position the sub-menu
var uls = this.menu.getElementsByTagName('ul');
for (var i = 0; i < uls.length; i++) {
for (var i = 0; i < uls.length; ++i) {
var ul = uls[i];
if (ul.hasClass('scrollableMenu'))
ul.setStyle('max-height', scrollableMenuMaxHeight);

View file

@ -75,7 +75,7 @@ var DynamicTable = new Class({
var n = 2;
while (panel.clientWidth != panel.offsetWidth && n > 0) { // is panel vertical scrollbar visible ?
n--;
--n;
h -= 0.5;
$(this.dynamicTableDivId).style.height = h + 'px';
}
@ -214,7 +214,7 @@ var DynamicTable = new Class({
var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId).split(',');
val.erase(el.columnName);
var pos = val.indexOf(this.lastHoverTh.columnName);
if (this.dropSide === 'right') pos++;
if (this.dropSide === 'right') ++pos;
val.splice(pos, 0, el.columnName);
localStorage.setItem('columns_order_' + this.dynamicTableDivId, val.join(','));
this.loadColumnsOrder();
@ -239,7 +239,7 @@ var DynamicTable = new Class({
var ths = this.fixedTableHeader.getElements('th');
for (var i = 0; i < ths.length; i++) {
for (var i = 0; i < ths.length; ++i) {
var th = ths[i];
th.addEvent('mousemove', mouseMoveFn);
th.addEvent('mouseout', mouseOutFn);
@ -262,7 +262,7 @@ var DynamicTable = new Class({
DynamicTableHeaderContextMenuClass = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
for (var i = 0; i < this.dynamicTable.columns.length; i++) {
for (var i = 0; i < this.dynamicTable.columns.length; ++i) {
if (this.dynamicTable.columns[i].caption === '')
continue;
if (this.dynamicTable.columns[i].visible !== '0')
@ -304,7 +304,7 @@ var DynamicTable = new Class({
this.showColumn(action, this.columns[action].visible === '0');
}.bind(this);
for (var i = 0; i < this.columns.length; i++) {
for (var i = 0; i < this.columns.length; ++i) {
var text = this.columns[i].caption;
if (text === '')
continue;
@ -370,17 +370,17 @@ var DynamicTable = new Class({
columnsOrder.push(v);
}.bind(this));
for (i = 0; i < this.columns.length; i++)
for (i = 0; i < this.columns.length; ++i)
if (!columnsOrder.contains(this.columns[i].name))
columnsOrder.push(this.columns[i].name);
for (i = 0; i < this.columns.length; i++)
for (i = 0; i < this.columns.length; ++i)
this.columns[i] = this.columns[columnsOrder[i]];
},
saveColumnsOrder: function() {
val = '';
for (i = 0; i < this.columns.length; i++) {
for (i = 0; i < this.columns.length; ++i) {
if (i > 0)
val += ',';
val += this.columns[i].name;
@ -396,7 +396,7 @@ var DynamicTable = new Class({
updateHeader: function(header) {
var ths = header.getElements('th');
for (var i = 0; i < ths.length; i++) {
for (var i = 0; i < ths.length; ++i) {
th = ths[i];
th._this = this;
th.setAttribute('title', this.columns[i].caption);
@ -411,7 +411,7 @@ var DynamicTable = new Class({
},
getColumnPos: function(columnName) {
for (var i = 0; i < this.columns.length; i++)
for (var i = 0; i < this.columns.length; ++i)
if (this.columns[i].name == columnName)
return i;
return -1;
@ -431,13 +431,13 @@ var DynamicTable = new Class({
if (visible) {
ths[pos].removeClass('invisible');
fths[pos].removeClass('invisible');
for (var i = 0; i < trs.length; i++)
for (var i = 0; i < trs.length; ++i)
trs[i].getElements('td')[pos].removeClass('invisible');
}
else {
ths[pos].addClass('invisible');
fths[pos].addClass('invisible');
for (var j = 0; j < trs.length; j++)
for (var j = 0; j < trs.length; ++j)
trs[j].getElements('td')[pos].addClass('invisible');
}
if (this.columns[pos].onResize !== null) {
@ -484,7 +484,7 @@ var DynamicTable = new Class({
this.selectedRows.empty();
var trs = this.tableBody.getElements('tr');
for (var i = 0; i < trs.length; i++) {
for (var i = 0; i < trs.length; ++i) {
var tr = trs[i];
this.selectedRows.push(tr.rowId);
if (!tr.hasClass('selected'))
@ -543,7 +543,7 @@ var DynamicTable = new Class({
var rows = this.rows.getValues();
for (i = 0; i < rows.length; i++) {
for (i = 0; i < rows.length; ++i) {
filteredRows.push(rows[i]);
filteredRows[rows[i].rowId] = rows[i];
}
@ -561,7 +561,7 @@ var DynamicTable = new Class({
getTrByRowId: function(rowId) {
trs = this.tableBody.getElements('tr');
for (var i = 0; i < trs.length; i++)
for (var i = 0; i < trs.length; ++i)
if (trs[i].rowId == rowId)
return trs[i];
return null;
@ -573,18 +573,18 @@ var DynamicTable = new Class({
var rows = this.getFilteredAndSortedRows();
for (var i = 0; i < this.selectedRows.length; i++)
for (var i = 0; i < this.selectedRows.length; ++i)
if (!(this.selectedRows[i] in rows)) {
this.selectedRows.splice(i, 1);
i--;
--i;
}
var trs = this.tableBody.getElements('tr');
for (var rowPos = 0; rowPos < rows.length; rowPos++) {
for (var rowPos = 0; rowPos < rows.length; ++rowPos) {
var rowId = rows[rowPos]['rowId'];
tr_found = false;
for (var j = rowPos; j < trs.length; j++)
for (var j = rowPos; j < trs.length; ++j)
if (trs[j]['rowId'] == rowId) {
tr_found = true;
if (rowPos == j)
@ -632,7 +632,7 @@ var DynamicTable = new Class({
this._this.selectedRows.empty();
var trs = this._this.tableBody.getElements('tr');
var select = false;
for (var i = 0; i < trs.length; i++) {
for (var i = 0; i < trs.length; ++i) {
var tr = trs[i];
if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) {
@ -660,7 +660,7 @@ var DynamicTable = new Class({
this.setupTr(tr);
for (var k = 0; k < this.columns.length; k++) {
for (var k = 0; k < this.columns.length; ++k) {
var td = new Element('td');
if ((this.columns[k].visible == '0') || this.columns[k].force_hide)
td.addClass('invisible');
@ -700,7 +700,7 @@ var DynamicTable = new Class({
data = row[fullUpdate ? 'full_data' : 'data'];
tds = tr.getElements('td');
for (var i = 0; i < this.columns.length; i++) {
for (var i = 0; i < this.columns.length; ++i) {
if (data.hasOwnProperty(this.columns[i].dataProperties[0]))
this.columns[i].updateTd(tds[i], row);
}
@ -966,7 +966,7 @@ var TorrentsTable = new Class({
var pos = this.getColumnPos(columnName);
var trs = this.tableBody.getElements('tr');
ProgressColumnWidth = -1;
for (var i = 0; i < trs.length; i++) {
for (var i = 0; i < trs.length; ++i) {
var td = trs[i].getElements('td')[pos];
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
@ -1158,8 +1158,8 @@ var TorrentsTable = new Class({
var cnt = 0;
var rows = this.rows.getValues();
for (i = 0; i < rows.length; i++)
if (this.applyFilter(rows[i], filterName, categoryHash)) cnt++;
for (i = 0; i < rows.length; ++i)
if (this.applyFilter(rows[i], filterName, categoryHash)) ++cnt;
return cnt;
},
@ -1167,7 +1167,7 @@ var TorrentsTable = new Class({
var rowsHashes = [];
var rows = this.rows.getValues();
for (i = 0; i < rows.length; i++)
for (i = 0; i < rows.length; ++i)
if (this.applyFilter(rows[i], filterName, categoryHash))
rowsHashes.push(rows[i]['rowId']);
@ -1179,7 +1179,7 @@ var TorrentsTable = new Class({
var rows = this.rows.getValues();
for (i = 0; i < rows.length; i++)
for (i = 0; i < rows.length; ++i)
if (this.applyFilter(rows[i], selected_filter, selected_category)) {
filteredRows.push(rows[i]);
filteredRows[rows[i].rowId] = rows[i];
@ -1284,7 +1284,7 @@ var TorrentPeersTable = new Class({
var a = ip1.split(".");
var b = ip2.split(".");
for (var i = 0; i < 4; i++) {
for (var i = 0; i < 4; ++i) {
if (a[i] != b[i])
return a[i] - b[i];
}

View file

@ -169,7 +169,7 @@ initializeWindows = function() {
var torrentsHaveSameShareRatio = true;
// check if all selected torrents have same share ratio
for (var i = 0; i < hashes.length; i++) {
for (var i = 0; i < hashes.length; ++i) {
var hash = hashes[i];
var row = torrentsTable.rows[hash].full_data;
var origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.max_ratio + "|" + row.max_seeding_time;
@ -575,7 +575,7 @@ initializeWindows = function() {
var names = [];
if (selectedRows.length) {
var rows = torrentsTable.getFilteredAndSortedRows();
for (var i = 0; i < selectedRows.length; i++) {
for (var i = 0; i < selectedRows.length; ++i) {
var hash = selectedRows[i];
names.push(rows[hash].full_data.name);
}
@ -588,7 +588,7 @@ initializeWindows = function() {
var magnets = [];
if (selectedRows.length) {
var rows = torrentsTable.getFilteredAndSortedRows();
for (var i = 0; i < selectedRows.length; i++) {
for (var i = 0; i < selectedRows.length; ++i) {
var hash = selectedRows[i];
magnets.push(rows[hash].full_data.magnet_uri);
}

View file

@ -201,7 +201,7 @@ var filesDynTable = new Class({
updateRow: function(tr, row, id) {
var tds = tr.getElements('td');
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
switch (i) {
case 0:
if (row[i] > 0)
@ -238,7 +238,7 @@ var filesDynTable = new Class({
//this.removeRow(id);
var tr = new Element('tr');
this.rows.set(id, tr);
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
var td = new Element('td');
switch (i) {
case 0:
@ -321,7 +321,7 @@ var loadTorrentFilesData = function() {
row[6] = friendlyPercentage(file.availability);
fTable.insertRow(i, row);
i++;
++i;
}.bind(this));
// Set global CB state
if (allCBChecked()) {

View file

@ -25,7 +25,7 @@ var trackersDynTable = new Class({
updateRow: function(tr, row) {
var tds = tr.getElements('td');
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
tds[i].set('html', row[i]);
}
return true;
@ -41,7 +41,7 @@ var trackersDynTable = new Class({
//this.removeRow(id);
var tr = new Element('tr');
this.rows.set(url, tr);
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
var td = new Element('td');
td.set('html', row[i]);
td.injectInside(tr);

View file

@ -25,7 +25,7 @@ var webseedsDynTable = new Class({
updateRow: function(tr, row) {
var tds = tr.getElements('td');
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
tds[i].set('html', row[i]);
}
return true;
@ -41,7 +41,7 @@ var webseedsDynTable = new Class({
//this.removeRow(id);
var tr = new Element('tr');
this.rows.set(url, tr);
for (var i = 0; i < row.length; i++) {
for (var i = 0; i < row.length; ++i) {
var td = new Element('td');
td.set('html', row[i]);
td.injectInside(tr);