mirror of https://github.com/ecmwf/eccodes.git
ECC-1820: Accessor hash
This commit is contained in:
parent
e0f2213627
commit
f0b68e4b15
|
@ -51,8 +51,7 @@ struct accessor_class_hash { const char *name; grib_accessor_class **cclass;};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
static unsigned int
|
static unsigned int grib_accessor_classes_get_id (const char *str, size_t len)
|
||||||
grib_accessor_classes_get_id (const char *str, size_t len)
|
|
||||||
{
|
{
|
||||||
static const unsigned short asso_values[] =
|
static const unsigned short asso_values[] =
|
||||||
{
|
{
|
||||||
|
@ -622,20 +621,19 @@ static const struct accessor_class_hash classes[] =
|
||||||
{"g1verificationdate", &grib_accessor_class_g1verificationdate}
|
{"g1verificationdate", &grib_accessor_class_g1verificationdate}
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct accessor_class_hash *
|
static const struct accessor_class_hash* grib_accessor_classes_hash(const char *str, size_t len)
|
||||||
grib_accessor_classes_hash (const char *str, size_t len)
|
|
||||||
{
|
|
||||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
|
||||||
{
|
{
|
||||||
unsigned int key = grib_accessor_classes_get_id (str, len);
|
unsigned int key = grib_accessor_classes_get_id (str, len);
|
||||||
|
|
||||||
if (key <= MAX_HASH_VALUE)
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
const char *s = classes[key].name;
|
const char *s;
|
||||||
|
Assert( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH );
|
||||||
if (*str == *s && !strcmp (str + 1, s + 1))
|
Assert( key <= MAX_HASH_VALUE );
|
||||||
return &classes[key];
|
s = classes[key].name;
|
||||||
}
|
Assert( *str == *s && strcmp(str + 1, s + 1)==0 );
|
||||||
}
|
}
|
||||||
return 0;
|
#endif
|
||||||
|
|
||||||
|
return &classes[key];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue