From 5ddbf9bba9236375a03ccb4143ec5f48877191d9 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 31 May 2018 01:06:28 +0800 Subject: [PATCH] Replace post-increment with pre-increment And post-decrement with pre-decrement. --- src/base/net/smtp.cpp | 2 +- src/base/preferences.cpp | 2 +- src/base/utils/string.cpp | 2 +- src/gui/properties/peerlistwidget.cpp | 8 +-- src/gui/search/pluginselectdlg.cpp | 2 +- src/gui/search/searchtab.cpp | 8 +-- src/gui/torrentcontentfiltermodel.cpp | 2 +- src/gui/transferlistwidget.cpp | 8 +-- .../www/private/preferences_content.html | 2 +- src/webui/www/private/scripts/client.js | 2 +- src/webui/www/private/scripts/contextmenu.js | 2 +- src/webui/www/private/scripts/dynamicTable.js | 56 +++++++++---------- src/webui/www/private/scripts/mocha-init.js | 6 +- src/webui/www/private/scripts/prop-files.js | 6 +- .../www/private/scripts/prop-trackers.js | 4 +- .../www/private/scripts/prop-webseeds.js | 4 +- 16 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 467afcad6..4342fb548 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -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 } diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index 9016b175c..9b2a143ef 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -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; diff --git a/src/base/utils/string.cpp b/src/base/utils/string.cpp index 65430309b..e8ddcffcb 100644 --- a/src/base/utils/string.cpp +++ b/src/base/utils/string.cpp @@ -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); diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 67cbb9e6a..e897b4aaf 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -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; diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index 79d9d562a..f8e8a90e5 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -424,7 +424,7 @@ void PluginSelectDlg::checkForUpdatesFinished(const QHashupdatePlugin(i.key()); } } diff --git a/src/gui/search/searchtab.cpp b/src/gui/search/searchtab.cpp index 6f157be2c..bd3102c01 100644 --- a/src/gui/search/searchtab.cpp +++ b/src/gui/search/searchtab.cpp @@ -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; diff --git a/src/gui/torrentcontentfiltermodel.cpp b/src/gui/torrentcontentfiltermodel.cpp index 41419748e..d23b2db60 100644 --- a/src/gui/torrentcontentfiltermodel.cpp +++ b/src/gui/torrentcontentfiltermodel.cpp @@ -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)) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 4f86d05e3..3b801d78e 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -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 1) break; diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 29a3e2ef9..ec2ca4c7d 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -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; diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 3c4f67b74..e0c5e9967 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -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; } diff --git a/src/webui/www/private/scripts/contextmenu.js b/src/webui/www/private/scripts/contextmenu.js index e21b0c87e..5973a8e69 100644 --- a/src/webui/www/private/scripts/contextmenu.js +++ b/src/webui/www/private/scripts/contextmenu.js @@ -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); diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 2d6027b53..b49f9d830 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -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]; } diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 39535adfa..e7386900c 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -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); } diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index fff20d550..66dd859b5 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -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()) { diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index fab9201c3..b6bf04617 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -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); diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index 494821537..009182e20 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -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);