ywangd / mspms2

Automatically exported from code.google.com/p/mspms2
0 stars 1 forks source link

Use Function pointer to avoid switch/case #39

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Use switch/case very frequently to check which segment of code to be
executed is not efficient.

We can use Function pointer to link a generic function to the function that
needs to be executed. In the code, just call the generic function Thus
avoid the switch/case check. For an example, the generic function pointer
can be set to the address of different bond potential functions. Therefore,
we only need to set the address once and call the function pointer. This
should improve the performance.

Original issue reported on code.google.com by ywa...@gmail.com on 19 Jan 2008 at 2:22