libschc icon indicating copy to clipboard operation
libschc copied to clipboard

schc_header_field_names very wasteful

Open miri64 opened this issue 3 years ago • 1 comments

There are two issues with the schc_header_field_names array with how it is currently implemented:

  1. 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 a field2str() function as an accessor function in case it is needed outside of compressor.c.
  2. It uses schc_header_fields as indexes, of which IP6_V has 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.

miri64 avatar Nov 02 '22 10:11 miri64

Agreed. I'll have a look at this.

bartmoons avatar Nov 14 '22 09:11 bartmoons