From 0420591b35b18618c5f307e231faca73ee1d2096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Rognes?= Date: Mon, 1 Mar 2021 17:07:08 +0100 Subject: [PATCH] Remove MIN and MAX macros --- src/algo.cc | 6 +++--- src/bloompat.cc | 2 +- src/nw.cc | 8 ++++---- src/swarm.cc | 6 +++--- src/swarm.h | 12 +----------- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/algo.cc b/src/algo.cc index 3783a048..f5629afa 100644 --- a/src/algo.cc +++ b/src/algo.cc @@ -126,9 +126,9 @@ void algo_run(struct Parameters const & p) (xmalloc(amplicons * sizeof(uint64_t))); auto diff_saturation - = static_cast(MIN(UINT8_MAX / penalty_mismatch, - UINT8_MAX / (penalty_gapopen + - penalty_gapextend))); + = static_cast(std::min(UINT8_MAX / penalty_mismatch, + UINT8_MAX / (penalty_gapopen + + penalty_gapextend))); unsigned char * dir {nullptr}; uint64_t * hearray {nullptr}; diff --git a/src/bloompat.cc b/src/bloompat.cc index f467c8f1..0e307aff 100644 --- a/src/bloompat.cc +++ b/src/bloompat.cc @@ -64,7 +64,7 @@ auto bloom_init(uint64_t size) -> struct bloom_s * { // Size is in bytes for full bitmap, must be power of 2 // at least 8 - size = MAX(size, 8); + size = std::max(size, static_cast(8)); auto * b = static_cast(xmalloc(sizeof(struct bloom_s))); diff --git a/src/nw.cc b/src/nw.cc index a8d49729..b81697c1 100644 --- a/src/nw.cc +++ b/src/nw.cc @@ -165,8 +165,8 @@ void nw(char * dseq, +(nt_extract(qseq, static_cast(i)) + 1)]; dir[index] |= (f < h ? maskup : 0); - h = MIN(h, f); - h = MIN(h, e); + h = std::min(h, f); + h = std::min(h, e); dir[index] |= (e == h ? maskleft : 0); *hep = h; @@ -177,8 +177,8 @@ void nw(char * dseq, dir[index] |= (f < h ? maskextup : 0); dir[index] |= (e < h ? maskextleft : 0); - f = MIN(h,f); - e = MIN(h,e); + f = std::min(h,f); + e = std::min(h,e); *(hep+1) = e; h = n; diff --git a/src/swarm.cc b/src/swarm.cc index 620ded43..d2084d30 100644 --- a/src/swarm.cc +++ b/src/swarm.cc @@ -787,9 +787,9 @@ auto main(int argc, char** argv) -> int penalty_gapopen /= penalty_factor; penalty_gapextend /= penalty_factor; - int64_t diff_saturation_16 = (MIN((UINT16_MAX / penalty_mismatch), - (UINT16_MAX - penalty_gapopen) - / penalty_gapextend)); + int64_t diff_saturation_16 = (std::min((UINT16_MAX / penalty_mismatch), + (UINT16_MAX - penalty_gapopen) + / penalty_gapextend)); if (p.opt_differences > diff_saturation_16) fatal("Resolution (d) too high for the given scoring system"); diff --git a/src/swarm.h b/src/swarm.h index 148c6614..8d369637 100644 --- a/src/swarm.h +++ b/src/swarm.h @@ -39,6 +39,7 @@ constexpr char PRId64[] = "ld"; #endif #endif +#include #include #include #include @@ -108,19 +109,8 @@ static_assert(INT_MAX > INT16_MAX, "Your compiler uses very short integers."); /* constants */ const std::string swarm_version = {"Swarm 3.0.0"}; -// constexpr unsigned int width {32}; // unused? -// constexpr unsigned int width_shift {5}; // unused? constexpr char sepchar {' '}; constexpr unsigned int bloom_bits_default {16}; - -#ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) -#endif - -#ifndef MAX -#define MAX(x,y) ((x)>(y)?(x):(y)) -#endif - constexpr unsigned int qgramlength {5}; constexpr unsigned int qgramvectorbits {1 << (2 * qgramlength)}; constexpr unsigned int qgramvectorbytes {qgramvectorbits / 8};