Skip to content

Commit 1b5ae82

Browse files
author
schutzekatze
committed
Memory optimization
1 parent c099f52 commit 1b5ae82

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

RResolver/RAlgorithmsShort.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Support
8383
{
8484
public:
8585

86-
enum class UnknownReason : unsigned {
86+
enum class UnknownReason : uint8_t {
8787
UNDETERMINED = 0, // Not yet processed
8888
TOO_MANY_COMBINATIONS, // Branching out exploded beyond a threshold
8989
OVER_MAX_TESTS, // Planned tests was above the threshold
@@ -102,13 +102,15 @@ class Support
102102
Support(int calculatedTests, UnknownReason unknownReason)
103103
: found(-1)
104104
, tests(-1)
105-
, calculatedTests(calculatedTests)
106105
, unknownReason(unknownReason)
107106
{
108107
assert(calculatedTests >= 0);
108+
if (calculatedTests > std::numeric_limits<decltype(this->calculatedTests)>::max()) { this->calculatedTests = std::numeric_limits<decltype(this->calculatedTests)>::max(); } else {
109+
this->calculatedTests = calculatedTests;
110+
}
109111
}
110112

111-
Support(int found, int tests)
113+
Support(int8_t found, int8_t tests)
112114
: found(found)
113115
, tests(tests)
114116
{
@@ -117,14 +119,16 @@ class Support
117119
assert(calculatedTests == -1);
118120
}
119121

120-
Support(int found, int tests, int calculatedTests)
122+
Support(int8_t found, int8_t tests, int calculatedTests)
121123
: found(found)
122124
, tests(tests)
123-
, calculatedTests(calculatedTests)
124125
{
125126
assert(found >= 0);
126127
assert(tests > 0);
127128
assert(calculatedTests >= 0);
129+
if (calculatedTests > std::numeric_limits<decltype(this->calculatedTests)>::max()) { this->calculatedTests = std::numeric_limits<decltype(this->calculatedTests)>::max(); } else {
130+
this->calculatedTests = calculatedTests;
131+
}
128132
}
129133

130134
bool unknown() const { return tests == -1; }
@@ -141,9 +145,9 @@ class Support
141145

142146
bool operator<(const Support& s) { return found < s.found; }
143147

144-
int found = -1;
145-
int tests = -1;
146-
int calculatedTests = -1;
148+
int8_t found = -1;
149+
int8_t tests = -1;
150+
int8_t calculatedTests = -1;
147151
UnknownReason unknownReason = UnknownReason::UNDETERMINED;
148152
};
149153

RResolver/RResolverShort.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const char USAGE_MESSAGE[] =
4848
" Histograms are omitted if no prefix is given."
4949
" -t, --threshold=N set path support threshold to N. [4]"
5050
" -x, --extract=N extract N rmers per read. [4]"
51-
" -m, --min-tests=N set minimum number of sliding window moves to N. [20]"
51+
" -m, --min-tests=N set minimum number of sliding window moves to N. Maximum value is 127. [20]"
5252
" -n, --branching=N set maximum number of branching paths to N. [75]"
5353
" -r, --rmer=N explicitly set r value (k value used by rresolver)."
5454
" The number of set r values should be equalto the number of read sizes."

0 commit comments

Comments
 (0)