Skip to content

Commit a0f3a14

Browse files
UI: replace vector with set for wallet property list (thanks @dexX7)
1 parent 165ec4e commit a0f3a14

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/omnicore/omnicore.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ std::map<uint32_t, int64_t> global_balance_money;
110110
//! Reserved balances of wallet propertiess
111111
std::map<uint32_t, int64_t> global_balance_reserved;
112112
//! Vector containing a list of properties relative to the wallet
113-
std::vector<uint32_t> global_wallet_property_list;
113+
std::set<uint32_t> global_wallet_property_list;
114114

115115
/**
116116
* Used to indicate, whether to automatically commit created transactions.
@@ -620,10 +620,8 @@ void mastercore::set_wallet_totals()
620620
my_it->second.init();
621621
uint32_t propertyId;
622622
while (0 != (propertyId = (my_it->second).next())) {
623-
// add to the global wallet property list (avoiding duplicates)
624-
if (std::find(global_wallet_property_list.begin(), global_wallet_property_list.end(), propertyId) == global_wallet_property_list.end()) {
625-
global_wallet_property_list.push_back(propertyId);
626-
}
623+
// add to the global wallet property list
624+
global_wallet_property_list.insert(propertyId);
627625

628626
// check if the address is spendable (only spendable balances are included in totals)
629627
if (addressIsMine != ISMINE_SPENDABLE) continue;
@@ -635,9 +633,6 @@ void mastercore::set_wallet_totals()
635633
global_balance_reserved[propertyId] += getMPbalance(address, propertyId, ACCEPT_RESERVE);
636634
}
637635
}
638-
639-
// sort the global wallet property list
640-
std::sort (global_wallet_property_list.begin(), global_wallet_property_list.end());
641636
}
642637

643638
int TXExodusFundraiser(const CTransaction &wtx, const string &sender, int64_t ExodusHighestValue, int nBlock, unsigned int nTime)

src/omnicore/omnicore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CTransaction;
2828
#include <map>
2929
#include <string>
3030
#include <vector>
31+
#include <set>
3132

3233
using json_spirit::Array;
3334

@@ -387,7 +388,7 @@ extern std::map<uint32_t, int64_t> global_balance_money;
387388
//! Reserved balances of wallet propertiess
388389
extern std::map<uint32_t, int64_t> global_balance_reserved;
389390
//! Vector containing a list of properties relative to the wallet
390-
extern std::vector<uint32_t> global_wallet_property_list;
391+
extern std::set<uint32_t> global_wallet_property_list;
391392

392393

393394
int64_t getMPbalance(const string &Address, uint32_t property, TallyType ttype);

src/qt/balancesdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void BalancesDialog::UpdatePropSelector()
137137
ui->propSelectorWidget->clear();
138138
ui->propSelectorWidget->addItem("Wallet Totals (Summary)","2147483646"); //use last possible ID for summary for now
139139
// populate property selector
140-
for (std::vector<uint32_t>::iterator it = global_wallet_property_list.begin() ; it != global_wallet_property_list.end(); ++it) {
140+
for (std::set<uint32_t>::iterator it = global_wallet_property_list.begin() ; it != global_wallet_property_list.end(); ++it) {
141141
uint32_t propertyId = *it;
142142
std::string spId = static_cast<ostringstream*>( &(ostringstream() << propertyId) )->str();
143143
std::string spName = getPropertyName(propertyId).c_str();
@@ -176,7 +176,7 @@ void BalancesDialog::PopulateBalances(unsigned int propertyId)
176176
ui->balancesTable->setHorizontalHeaderItem(1, new QTableWidgetItem("Property Name"));
177177

178178
// loop over the wallet property list and add the wallet totals
179-
for (std::vector<uint32_t>::iterator it = global_wallet_property_list.begin() ; it != global_wallet_property_list.end(); ++it) {
179+
for (std::set<uint32_t>::iterator it = global_wallet_property_list.begin() ; it != global_wallet_property_list.end(); ++it) {
180180
uint32_t propertyId = *it;
181181
std::string spId = static_cast<ostringstream*>( &(ostringstream() << propertyId) )->str();
182182
std::string spName = getPropertyName(propertyId).c_str();

0 commit comments

Comments
 (0)