mirror of https://github.com/ecmwf/eccodes.git
ECC-1003: Performance: Use faster shift operator rather than power function
This commit is contained in:
parent
aef9a9ca21
commit
ec0d4c0311
|
@ -359,7 +359,8 @@ static grib_codetable* load_table(grib_accessor_codetable* self)
|
|||
} else {
|
||||
size = grib_byte_count((grib_accessor*)self) * 8;
|
||||
}
|
||||
size = grib_power(size,2);
|
||||
|
||||
size = (1UL << size); /* 2^size */
|
||||
|
||||
t = (grib_codetable*)grib_context_malloc_clear_persistent(c,sizeof(grib_codetable) +
|
||||
(size-1)*sizeof(code_table_entry));
|
||||
|
|
|
@ -281,7 +281,7 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
|
|||
next = next->next;
|
||||
}
|
||||
|
||||
size = grib_power(self->widthOfCode,2);
|
||||
size = (1UL << self->widthOfCode); /* 2 ^ self->widthOfCode */
|
||||
|
||||
t = (grib_smart_table*)grib_context_malloc_clear_persistent(c,sizeof(grib_smart_table));
|
||||
t->entries=(grib_smart_table_entry*)grib_context_malloc_clear_persistent(c,size*sizeof(grib_smart_table_entry));
|
||||
|
@ -473,7 +473,7 @@ static int get_table_codes(grib_accessor* a)
|
|||
|
||||
if (!self->dirty) return 0;
|
||||
|
||||
table_size = grib_power(self->widthOfCode,2);
|
||||
table_size = (1 << self->widthOfCode); /* 2 ^ self->widthOfCode */
|
||||
|
||||
if(!self->table)
|
||||
self->table = load_table(self);
|
||||
|
|
Loading…
Reference in New Issue