CAIDA / libparsebgp

Lightweight parser for binary BGP, BMP and MRT routing data
https://bgpstream.caida.org
BSD 2-Clause "Simplified" License
8 stars 8 forks source link

Consider using arrays of function pointers instead of switch statements for type-specific parsers #27

Closed alistairking closed 7 years ago

alistairking commented 7 years ago

There are several disadvantages to using function pointers in this case. For example, we would be forced to pass the msg parameter as a void*, so we'd lose some compile-time security there, and potentially loss of optimization.

However, it is worth benchmarking since we'd be removing the overhead of the switch (which could be significant depending on how the compiler decides to implement it).

alistairking commented 7 years ago

I tried this (while using a profiler) on a small scale a while back and it didn't seem to have any impact. I'm going to close this for now.