Optimisation: faster decode for constant field

This commit is contained in:
Shahram Najm 2022-03-01 18:03:43 +00:00
parent 559a25dd39
commit cc09ad375d
2 changed files with 23 additions and 4 deletions

View File

@ -214,7 +214,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
grib_handle* hand = grib_handle_of_accessor(a);
int err = GRIB_SUCCESS, i = 0;
size_t buflen = grib_byte_count(a);
size_t buflen = 0;
struct aec_stream strm;
double bscale = 0;
double dscale = 0;
@ -260,9 +260,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS)
return err;
bscale = grib_power(binary_scale_factor, 2);
dscale = grib_power(-decimal_scale_factor, 10);
/* TODO: This should be called upstream */
if (*len < n_vals)
return GRIB_ARRAY_TOO_SMALL;
@ -275,6 +272,10 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return GRIB_SUCCESS;
}
bscale = grib_power(binary_scale_factor, 2);
dscale = grib_power(-decimal_scale_factor, 10);
buflen = grib_byte_count(a);
buf = (unsigned char*)hand->buffer->data;
buf += grib_byte_offset(a);

View File

@ -1,6 +1,24 @@
set -ea
# For CMake
# Unset any environment variable that could interfere with tests
unset ECCODES_EXTRA_DEFINITION_PATH
unset ECCODES_LOG_STREAM
unset ECCODES_FAIL_IF_LOG_MESSAGE
unset ECCODES_DEBUG
unset ECCODES_GRIB_WRITE_ON_FAIL
unset ECCODES_GRIB_DATA_QUALITY_CHECKS
unset ECCODES_GRIB_KEEP_MATRIX
unset ECCODES_GRIB_NO_SPD
unset ECCODES_GRIB_NO_BIG_GROUP_SPLIT
unset ECCODES_GRIB_IEEE_PACKING
unset ECCODES_GRIBEX_MODE_ON
unset ECCODES_BUFRDC_MODE_ON
unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE
unset ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS
unset ECCODES_FILE_POOL_MAX_OPENED_FILES
unset ECCODES_IO_BUFFER_SIZE
set -x
echo "Script: $0"