Currently, when the stseq function recursively runs to store internal table information for a standard Table D descriptor, it doesn't keep track of which RPSEQ### sequences it has already generated, which means duplication can occur such as the following snippet from a run of the debufr utility on test/testfiles/IN_4:
and then replace all occurrences of RPSEQ00[3-7] and RPSEQ00[89] with, respectively, RPSEQ003 and RPSEQ004 in the prior MSTTB001 definition. To do this would likely just require stseq to start keeping its own internal sequence cache between recursive calls, and then before each instance where it currently calls igettdi and stseq to store a new RPSEQxxx sequence with xxx = irepct+1, it first checks its internal cache of existing RPSEQyyy sequences where yyy = 0, 1, 2, ..., irepct to see whether an identical sequence has already been stored, and if so just re-uses that same RPSEQyyy sequence instead of calling igettdi and stseq to store a new one.
Off the top of my head, I'm thinking this cache of already-stored RPSEQyyy mnemonics and corresponding rpidn (i.e. FXY) numbers could be maintained in a separate new C function that's only ever called from within stseq. Of course, we'd also have to include a way to reset the cache back to yyy = 0 whenever stseq itself is called with irepct = 0.
Currently, when the stseq function recursively runs to store internal table information for a standard Table D descriptor, it doesn't keep track of which RPSEQ### sequences it has already generated, which means duplication can occur such as the following snippet from a run of the debufr utility on test/testfiles/IN_4:
So, for example, it might be useful to be able to replace the last 14 lines above with just:
and then replace all occurrences of
RPSEQ00[3-7]
andRPSEQ00[89]
with, respectively,RPSEQ003
andRPSEQ004
in the priorMSTTB001
definition. To do this would likely just require stseq to start keeping its own internal sequence cache between recursive calls, and then before each instance where it currently calls igettdi and stseq to store a new RPSEQxxx sequence with xxx = irepct+1, it first checks its internal cache of existing RPSEQyyy sequences where yyy = 0, 1, 2, ..., irepct to see whether an identical sequence has already been stored, and if so just re-uses that same RPSEQyyy sequence instead of calling igettdi and stseq to store a new one.Off the top of my head, I'm thinking this cache of already-stored RPSEQyyy mnemonics and corresponding rpidn (i.e. FXY) numbers could be maintained in a separate new C function that's only ever called from within stseq. Of course, we'd also have to include a way to reset the cache back to yyy = 0 whenever stseq itself is called with irepct = 0.