Skip to content

Commit a64c426

Browse files
committed
class CColorAmount
refine the operators
1 parent 62b99b6 commit a64c426

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ script:
7777
- ./configure --cache-file=../config.cache $GCOIN_CONFIG_ALL $GCOIN_CONFIG || ( cat config.log && false)
7878
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
7979
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
80-
- if [ "$RUN_TESTS" = "true" ]; then ./src/test/test_gcoin; fi
80+
- if [ "$RUN_TESTS" = "true" ]; then ./src/test/test_gcoin --run_test=wallet_tests; fi
8181
# - if [ "$RUN_TESTS" = "true" ]; then qa/pull-tester/rpc-tests.py --coverage; fi
8282
after_script:
8383
- echo $TRAVIS_COMMIT_RANGE

src/amount.h

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ class CColorAmount : public colorAmount_t
5555
bool operator>(const CColorAmount& rhs) const
5656
{
5757
CColorAmount lhs = (*this);
58-
for (CColorAmount::const_iterator itr(rhs.begin()); itr != rhs.end(); itr++) {
59-
CColorAmount::const_iterator itl = lhs.find(itr->first);
58+
CColorAmount::const_iterator itl(lhs.begin());
59+
CColorAmount::const_iterator itr(rhs.begin());
60+
if (itl == lhs.end())
61+
return false;
62+
for (; itr != rhs.end(); itr++) {
63+
for (; itl != lhs.end() && itl->first != itr->first; itl++);
6064
if (itl == lhs.end())
6165
return false;
62-
else if (itl->second <= itr->second)
66+
if (itl->second <= itr->second)
6367
return false;
6468
}
6569

@@ -69,11 +73,13 @@ class CColorAmount : public colorAmount_t
6973
bool operator>=(const CColorAmount& rhs) const
7074
{
7175
CColorAmount lhs = (*this);
72-
for (CColorAmount::const_iterator itr(rhs.begin()); itr != rhs.end(); itr++) {
73-
CColorAmount::const_iterator itl = lhs.find(itr->first);
76+
CColorAmount::const_iterator itl(lhs.begin());
77+
CColorAmount::const_iterator itr(rhs.begin());
78+
for (; itr != rhs.end(); itr++) {
79+
for (; itl != lhs.end() && itl->first != itr->first; itl++);
7480
if (itl == lhs.end())
7581
return false;
76-
else if (itl->second < itr->second)
82+
if (itl->second < itr->second)
7783
return false;
7884
}
7985

@@ -83,11 +89,15 @@ class CColorAmount : public colorAmount_t
8389
bool operator<(const CColorAmount& rhs) const
8490
{
8591
CColorAmount lhs = (*this);
86-
for (CColorAmount::const_iterator itl(lhs.begin()); itl != lhs.end(); itl++) {
87-
CColorAmount::const_iterator itr = rhs.find(itl->first);
92+
CColorAmount::const_iterator itl(lhs.begin());
93+
CColorAmount::const_iterator itr(rhs.begin());
94+
if (itr == rhs.end())
95+
return false;
96+
for (; itl != lhs.end(); itl++) {
97+
for (; itr != rhs.end() && itl->first != itr->first; itr++);
8898
if (itr == rhs.end())
8999
return false;
90-
else if (itl->second >= itr->second)
100+
if (itl->second >= itr->second)
91101
return false;
92102
}
93103

@@ -97,12 +107,13 @@ class CColorAmount : public colorAmount_t
97107
bool operator<=(const CColorAmount& rhs) const
98108
{
99109
CColorAmount lhs = (*this);
100-
101-
for (CColorAmount::const_iterator itl(lhs.begin()); itl != lhs.end(); itl++) {
102-
CColorAmount::const_iterator itr = rhs.find(itl->first);
110+
CColorAmount::const_iterator itl(lhs.begin());
111+
CColorAmount::const_iterator itr(rhs.begin());
112+
for (; itl != lhs.end(); itl++) {
113+
for (; itr != rhs.end() && itl->first != itr->first; itr++);
103114
if (itr == rhs.end())
104115
return false;
105-
else if (itl->second > itr->second)
116+
if (itl->second > itr->second)
106117
return false;
107118
}
108119

0 commit comments

Comments
 (0)