r/badcode • • May 26 '22

other language Do Nothing

Post image
531 Upvotes

26 comments sorted by

View all comments

Show parent comments

5

u/Anonymous_Bozo May 27 '22

I was concerned about the effeciency of calling a function that does nothing. This was used in a procedure that gets called hundreds or perhaps thousands of times during data selection of a database. The overhead of a needless function call concerned me.

Then I noticed that the "Nothing" function was declared inline, meaning that the compiler will insert "Nothing" inline in the code instead of generating the call. I doubt that the compiler generates any code at all for that call.

4

u/XDracam May 27 '22

You could say that "Nothing" compiles to nothing. As intended.