ECC-1003: Performance: Use faster shift operator rather than power function

This commit is contained in:
Shahram Najm 2019-10-08 15:55:59 +01:00
parent aef9a9ca21
commit ec0d4c0311
2 changed files with 4 additions and 3 deletions

View File

@ -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));

View File

@ -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);