c9s / r3

libr3 is a high-performance path dispatching library. It compiles your route paths into a prefix tree (trie). By using the constructed prefix trie in the start-up time, you may dispatch your routes with efficiency
http://c9s.github.com/r3/bench.html
MIT License
814 stars 83 forks source link

Remove unnecessary null pointer checks #37

Closed elfring closed 10 years ago

elfring commented 10 years ago

An extra null pointer check is not needed in functions like the following.

Would you like to apply a semantic patch like the following to find more update candidates?

@Remove_unnecessary_pointer_checks@
expression x;
@@
-if (x)
    zfree(x);
c9s commented 10 years ago

sure

c9s commented 10 years ago

the pointer check is removed from str_array_free. fe5c238

the pointer check is required in r3_tree_free because not every field is used in each node.

elfring commented 10 years ago

The function "zfree" performs input parameter validation in its implementation so that you do not need to repeat corresponding checks before calling such a function by "r3_tree_free". (The field usage does not matter in this use case.)

c9s commented 10 years ago

Oh! that makes sense, thanks!

thedrow commented 10 years ago

I added those for debugging and forgot to remove them :/

c9s commented 10 years ago

I just cleaned up

elfring commented 10 years ago

Thanks for your small source code improvement.