![]() ![]() Also, if a return is placed in the middle of the. ![]() It can also enable further optimizations by simplifying program structure.įor example, consider the following code: foo 25) is replaced by expr1. Most of them when they see and infinite loop, will not compile anything in the function that follows that loop. Of course, tools can be created that recognize some instances of dead code and remove them. That is, we know that there is no algorithm that can remove all instances of dead code. The answer above (by Mureinik) explains how to fix that. There may be language-specific subtleties at work that prevent elimination of apparently dead code. The compiler spots that, and hence you get the 'dead code warning'. Removing such code has several benefits: it shrinks program size and it allows the running program to avoid executing irrelevant operations, which reduces its running time. The conceptual problem here is that dead code elimination is not computable. will not normally run because after the first inner loop executes, you are returning the new line character as a string, terminating the function at that point. You might wonder why someone would write this type of source code, but it can easily creep into large, long-lived programs even at the source code level. ![]() 'Dead code' refers to code that has no purpose or which is never run. new book has been added and it's name is t number of books in the libarary is : 1 new book has been added and it's name is z number of books in the libarary is : 2 new book has been added and it's name is Computer security number of books in the libarary is : 3 You have borrowed the book: You have borrowed the book: You have borrowed the book. Dead Code Elimination Dead Code Elimination Backgroundĭead Code Elimination is an optimization that removes code which does not affect the program results. For the same reason, the code increments the value of j, but j is never used, so the code does nothing. ![]()
0 Comments
Leave a Reply. |