mirror of https://github.com/sipwise/rtpengine.git
Instead of the previous approach using the strhash, introduce if-based lookup from `NG_COMMANDS`. The usage of strhash is deprecated because it: - forses string literals in switch cases, hence gives no possibility to use variables - makes then shortcuts using macro not possible to be used - it makes the part with the command find and actual commands definition duplicate, because one has to maintain both of them when adding/removing commands - switch is redundant and feels heavy, meanwhile the same thing can be generated using marco based on `NG_COMMANDS` introduced before, which are the main source of the truth Newer approach: - avoid usage of for/while cycles (because CPU consuming) - sorts the lookup based on the cmd name (string) length, what makes the command find efficient, because exlcludes unnecessary comparisons - uses the `memcmp()` at the very last - for example, for the "offer" command it may run the `memcmp()` only two times, because there are only two commands with the length 5 our of supported 35 commands in list now Additionally: include `string.h` for `memcmp()` operations. Change-Id: Iae70de87b88cd444ae162ba2b7c6aa7690731ee3mr26.1
parent
551ba3d82d
commit
cc5576476a
Loading…
Reference in new issue