samtools / htslib

C library for high-throughput sequencing data formats
Other
810 stars 447 forks source link

Add trivial le_to_u8() endianness routine #1494

Closed jmarshall closed 2 years ago

jmarshall commented 2 years ago

In writing a switch like this one in bcf_fmt_array():

https://github.com/samtools/htslib/blob/8d9193899ef3e34ea8ecc9f3fb72063e74697f69/vcf.c#L2386-L2392

  but in which the output types were unsigned rather than signed as in this one, I found that there was no le_to_u8() function. One could in fact just write BRANCH(uint8_t, *, …) in many such cases, but that is pretty obscure for the reader.

This is even more trivial than le_to_i8() but can be useful for the regular treatment of unsigned types in these sorts of switches.