BUFR dumpers: No need for inlined strcmp

This commit is contained in:
Shahram Najm 2022-12-27 16:16:56 +00:00
parent 30834ad7b9
commit 313867fa8b
10 changed files with 40 additions and 170 deletions

View File

@ -95,19 +95,6 @@ grib_dumper_class* grib_dumper_class_bufr_decode_C = &_grib_dumper_class_bufr_de
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -622,9 +609,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_decode_C* self = (grib_dumper_bufr_decode_C*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -638,7 +625,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -94,19 +94,6 @@ grib_dumper_class* grib_dumper_class_bufr_decode_filter = &_grib_dumper_class_bu
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -533,9 +520,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_decode_filter* self = (grib_dumper_bufr_decode_filter*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->begin = 1;
@ -550,7 +537,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->begin = 1;

View File

@ -95,19 +95,6 @@ grib_dumper_class* grib_dumper_class_bufr_decode_fortran = &_grib_dumper_class_b
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -563,9 +550,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_decode_fortran* self = (grib_dumper_bufr_decode_fortran*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -579,7 +566,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -95,19 +95,6 @@ grib_dumper_class* grib_dumper_class_bufr_decode_python = &_grib_dumper_class_bu
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -573,9 +560,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_decode_python* self = (grib_dumper_bufr_decode_python*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -589,7 +576,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -95,19 +95,6 @@ grib_dumper_class* grib_dumper_class_bufr_encode_C = &_grib_dumper_class_bufr_en
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -795,9 +782,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -810,7 +797,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -96,19 +96,6 @@ grib_dumper_class* grib_dumper_class_bufr_encode_filter = &_grib_dumper_class_bu
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -723,9 +710,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_encode_filter* self = (grib_dumper_bufr_encode_filter*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->begin = 1;
@ -739,7 +726,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->begin = 1;

View File

@ -96,19 +96,6 @@ grib_dumper_class* grib_dumper_class_bufr_encode_fortran = &_grib_dumper_class_b
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -841,9 +828,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -856,7 +843,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -95,19 +95,6 @@ grib_dumper_class* grib_dumper_class_bufr_encode_python = &_grib_dumper_class_bu
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -783,9 +770,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_encode_python* self = (grib_dumper_bufr_encode_python*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
grib_handle* h = grib_handle_of_accessor(a);
depth = 2;
self->empty = 1;
@ -798,7 +785,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
grib_dump_accessors_block(d, block);
depth -= 2;
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -94,19 +94,6 @@ grib_dumper_class* grib_dumper_class_bufr_simple = &_grib_dumper_class_bufr_simp
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static void init_class(grib_dumper_class* c) {}
static int init(grib_dumper* d)
@ -736,9 +723,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_bufr_simple* self = (grib_dumper_bufr_simple*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
int err = 0;
grib_handle* h = grib_handle_of_accessor(a);
self->empty = 1;
@ -753,7 +740,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
/*_dump_long_array(h,self->dumper.out,"inputOverriddenReferenceValues","inputOverriddenReferenceValues");*/
grib_dump_accessors_block(d, block);
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->empty = 1;

View File

@ -92,19 +92,6 @@ grib_dumper_class* grib_dumper_class_json = &_grib_dumper_class_json;
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a);
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
return 1;
while ((*a != 0 && *b != 0) && *(a) == *(b)) {
a++;
b++;
}
return (*a == 0 && *b == 0) ? 0 : 1;
}
static int depth = 0;
static void init_class(grib_dumper_class* c) {}
@ -539,9 +526,9 @@ static void dump_label(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_json* self = (grib_dumper_json*)d;
if (!grib_inline_strcmp(a->name, "BUFR") ||
!grib_inline_strcmp(a->name, "GRIB") ||
!grib_inline_strcmp(a->name, "META")) {
if (strcmp(a->name, "BUFR")==0 ||
strcmp(a->name, "GRIB")==0 ||
strcmp(a->name, "META")==0) {
depth = 2;
fprintf(self->dumper.out, "%-*s", depth, " ");
fprintf(self->dumper.out, "[\n");
@ -552,7 +539,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
depth -= 2;
fprintf(self->dumper.out, "\n]\n");
}
else if (!grib_inline_strcmp(a->name, "groupNumber")) {
else if (strcmp(a->name, "groupNumber")==0) {
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
if (!self->empty)