reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit c3f18d716fbc13f87c2ff18ec9177ef34e614504
parent 0acd3da61175cf28de4d7d3793400911f156f744
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon,  4 Jan 2016 22:32:18 -0500

mild refactoring & make less copies of string and remote objects

Diffstat:
Msrc/manager.cpp | 16++++++++--------
Msrc/reapack.cpp | 2+-
Msrc/report.cpp | 7+++----
3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/manager.cpp b/src/manager.cpp @@ -99,7 +99,7 @@ void Manager::onContextMenu(HWND target, const int x, const int y) menu.disable(); - const Remote remote = currentRemote(); + const Remote &remote = currentRemote(); if(!remote.isNull()) { if(isRemoteEnabled(remote)) @@ -124,7 +124,7 @@ void Manager::refresh() void Manager::setRemoteEnabled(const bool enabled) { - Remote remote = currentRemote(); + const Remote &remote = currentRemote(); if(remote.isNull()) return; @@ -147,9 +147,9 @@ void Manager::apply() { RemoteList *list = m_reapack->config()->remotes(); - for(auto it = m_enableOverrides.begin(); it != m_enableOverrides.end(); it++) { - const string &name = it->first; - const bool enable = it->second; + for(const auto &pair : m_enableOverrides) { + const string &name = pair.first; + const bool enable = pair.second; Remote remote = list->get(name); remote.setEnabled(enable); @@ -166,8 +166,8 @@ void Manager::reset() ListView::Row Manager::makeRow(const Remote &remote) const { - const auto_string name = make_autostring(remote.name()); - const auto_string url = make_autostring(remote.url()); + const auto_string &name = make_autostring(remote.name()); + const auto_string &url = make_autostring(remote.url()); return {name, url, isRemoteEnabled(remote) ? AUTO_STR("Enabled") : AUTO_STR("Disabled")}; @@ -180,7 +180,7 @@ Remote Manager::currentRemote() const if(index < 0) return {}; - const string remoteName = from_autostring(m_list->getRow(index)[0]); + const string &remoteName = from_autostring(m_list->getRow(index)[0]); return m_reapack->config()->remotes()->get(remoteName); } diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -135,7 +135,7 @@ void ReaPack::importRemote() RemoteList *remotes = m_config->remotes(); - const Remote existing = remotes->get(remote.name()); + const Remote &existing = remotes->get(remote.name()); if(!existing.isNull()) { if(existing.isProtected()) { diff --git a/src/report.cpp b/src/report.cpp @@ -21,6 +21,7 @@ #include "resource.hpp" #include "transaction.hpp" +#include <boost/range/adaptor/reversed.hpp> #include <sstream> using namespace std; @@ -57,7 +58,7 @@ void Report::onInit() if(updates) formatUpdates(text); - auto_string str = make_autostring(text.str()); + const auto_string &str = make_autostring(text.str()); SetDlgItemText(handle(), IDC_REPORT, str.c_str()); } @@ -88,9 +89,7 @@ void Report::formatUpdates(ostringstream &text) const Registry::QueryResult &regEntry = entry.second; const VersionSet &versions = pkg->versions(); - for(auto it = versions.rbegin(); it != versions.rend(); it++) { - Version *ver = *it; - + for(Version *ver : versions | boost::adaptors::reversed) { if(ver->code() <= regEntry.versionCode) break;