From 91eee4e164f941e83bbac6664fe7518ad9138502 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 25 Jun 2023 15:17:53 +0100 Subject: [PATCH] Dead code removal --- src/grib_bits_any_endian.cc | 22 +++++++++++----------- src/grib_bits_any_endian_omp.cc | 28 +++++++++++++--------------- src/grib_loader_from_array.cc | 2 +- src/grib_loader_from_handle.cc | 14 ++++++-------- src/md5.cc | 2 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/grib_bits_any_endian.cc b/src/grib_bits_any_endian.cc index 5f01b4106..6b9b810b5 100644 --- a/src/grib_bits_any_endian.cc +++ b/src/grib_bits_any_endian.cc @@ -10,7 +10,6 @@ /*************************************************************************** * Enrico Fucile - 19.06.2007 * - * * ***************************************************************************/ #ifdef ECCODES_ON_WINDOWS @@ -223,15 +222,16 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long return grib_decode_unsigned_long(p, bitp, bits); } -#if 0 - long ret2 = 0; - for(i=0; i< nbits;i++){ - ret2 <<= 1; - if(grib_get_bit( p, *bitp)) ret2 += 1; - *bitp += 1; - } - *bitp -= nbits; -#else + + // Old algorithm: + // long ret2 = 0; + // for(i=0; i< nbits;i++){ + // ret2 <<= 1; + // if(grib_get_bit( p, *bitp)) ret2 += 1; + // *bitp += 1; + // } + // *bitp -= nbits; + mask = BIT_MASK(nbits); /* pi: position of bitp in p[]. >>3 == /8 */ pi = oc; @@ -256,7 +256,7 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long /* remove leading bits (from previous value) */ ret &= mask; /* printf("%d %d\n", ret2, ret);*/ -#endif + return ret; } diff --git a/src/grib_bits_any_endian_omp.cc b/src/grib_bits_any_endian_omp.cc index fa726a19b..31e2c4df5 100644 --- a/src/grib_bits_any_endian_omp.cc +++ b/src/grib_bits_any_endian_omp.cc @@ -10,7 +10,6 @@ /*************************************************************************** * Enrico Fucile - 19.06.2007 * - * * ***************************************************************************/ /** * decode an array of n_vals values from a octet-stream @@ -81,20 +80,19 @@ int grib_decode_double_array(const unsigned char* p, long* bitp, long bitsPerVal unsigned long lvalue = 0; double x; -#if 0 - /* slow reference code */ - int j=0; - for(i=0;i < n_vals;i++) { - lvalue=0; - for(j=0; j< bitsPerValue;j++){ - lvalue <<= 1; - if(grib_get_bit( p, *bitp)) lvalue += 1; - *bitp += 1; - } - x=((lvalue*s)+reference_value)*d; - val[i] = (double)x; - } -#endif +// Slow reference code +// int j=0; +// for(i=0;i < n_vals;i++) { +// lvalue=0; +// for(j=0; j< bitsPerValue;j++){ +// lvalue <<= 1; +// if(grib_get_bit( p, *bitp)) lvalue += 1; +// *bitp += 1; +// } +// x=((lvalue*s)+reference_value)*d; +// val[i] = (double)x; +// } + unsigned long mask = BIT_MASK(bitsPerValue); /* pi: position of bitp in p[]. >>3 == /8 */ diff --git a/src/grib_loader_from_array.cc b/src/grib_loader_from_array.cc index 6db8c8bac..c60f233d1 100644 --- a/src/grib_loader_from_array.cc +++ b/src/grib_loader_from_array.cc @@ -172,7 +172,7 @@ int grib_lookup_long_from_array(grib_context* gc, grib_loader* loader, const cha // grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set %s to double, wrong type (%d)", // ga->name, type); // } -// #if 0 +// #if defined(OLD_IMPL) // switch(grib_accessor_get_native_type(ga)) // { // case GRIB_TYPE_STRING: diff --git a/src/grib_loader_from_handle.cc b/src/grib_loader_from_handle.cc index c3510c1c4..ccda34362 100644 --- a/src/grib_loader_from_handle.cc +++ b/src/grib_loader_from_handle.cc @@ -96,14 +96,12 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ return GRIB_SUCCESS; } -#if 0 - if(h->values) - if(copy_values(h,ga) == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); - return GRIB_SUCCESS; - } -#endif +// if(h->values) +// if(copy_values(h,ga) == GRIB_SUCCESS) +// { +// grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); +// return GRIB_SUCCESS; +// } #if 0 if(h->loader) diff --git a/src/md5.cc b/src/md5.cc index b039fa477..1d04a291b 100644 --- a/src/md5.cc +++ b/src/md5.cc @@ -275,7 +275,7 @@ void grib_md5_end(grib_md5_state* s, char* digest) U(s->h3 & 0xff), U((s->h3 >> 8) & 0xff), U((s->h3 >> 16) & 0xff), U((s->h3 >> 24) & 0xff)); } -#if 0 +#if defined(TESTING_MD5) main(int argc, char **argv) {