>+If you are going to reuse a computable value, save it in a variable
>+instead of recomputing it over and over.
>+
>+Just an Example:
>+
>+ if (strlen(name)) {
>+ newname = alloca(strlen(name));
>+ strncpy(newname, name, strlen(name);
>+ }
>+
>+vs
>+
>+ if((len = strlen(name))) {
>+ newname = alloca(len);
>+ strncpy(newname, name, len);
>+ }
Maybe they should point out that you need to make the memory versus CPU
cycles after you calculate the hit... i.e., using a nice amount of memory to
store a value that's easily computed is MUCH worse than wasting a few
hundred cycles, since one cache miss is gonna knock you back a lot...
-Michael
_______________________________________________
Asterisk-Dev mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev