optimize the encode function of DNA codec

On medium.sh:

Before:
  %   cumulative   self              self     total
   time   seconds   seconds    calls   s/call   s/call  name
  7.19      4.28     0.54  2631473     0.00     0.00  bsal_dna_codec_encode

After:
  %   cumulative   self              self     total
   time   seconds   seconds    calls   s/call   s/call  name
  0.39      9.89     0.04  1278965     0.00     0.00  bsal_dna_codec_encode

Link: https://github.com/GeneAssembly/biosal/issues/240
Signed-off-by: Sébastien Boisvert <boisvert@anl.gov>