libschc
libschc copied to clipboard
schc_header_field_names very wasteful
There are two issues with the schc_header_field_names array with how it is currently implemented:
- It is defined in a header file, i.e. it is created in ROM for every compile unit where it is included and used. Currently, it is only used in
compressor.c, so I would recommend moving its definition there and maybe provide afield2str()function as an accessor function in case it is needed outside ofcompressor.c. - It uses
schc_header_fieldsas indexes, of whichIP6_Vhas value 1024 defined. This means, that the first 1024 entries of the array are empty, so on a 64-bit platform 1024 * (64 / 8) = 8192, so 8kB are just wasted.
While this is only a debugging feature, it should also not add wasteful overhead. My proposal would be to decouple the CoAP option field values from the CoAP option values, which seems to be the reason, why IP6_V is defined at 1024, and have no jumps within the definition of schc_header_fields (i.e. have IP6_V be 0, and let the rest be defined by the enum order), so the schc_header_field_names array only uses as much space as it needs.
Agreed. I'll have a look at this.