Redundant code
In computer programming, redundant code is source code or compiled code that is unnecessary. Code that can be removed without affecting its desired behavior is redundant.
In computer programming, redundant code is source code or compiled code that is unnecessary. Code that can be removed without affecting its desired behavior is redundant. ==Categories== Notable categories of redundant code include: Recomputing: Calculating again a value that has previously been calculated and is still available. Dead code: Code that is executed but has no external effect (i.e., does not change the output produced by a program). Unreachable code: Code that is never executed (also called dead code). NOP padding: A NOP instruction might be considered redundant if it is for padding. But if the NOP is required for proper functionality, then it is not redundant. Unused identifier: Something declared, but never referenced, is a redundant declaration. ==Examples== In the following C code, the second x * 2 expression is redundant code. Line 2 can be removed, or alternatively, line 3 can be changed to . int foo(int x) { int y = x * 2; return x * 2; } A more subtle example involves the C preprocessor that inserts code before compilation. Consider: define min(A,B) ((A) After preprocessing, the code expands to code that evaluates both and twice. To eliminate the duplicate code, the macro could be converted to a function. int shorter_magnitude(int a, int b, int c, int d) { return sqrt(((a*a + b*b) ==See also== ==References==
References
- Debray, S. K., Evans, W., Muth, R., and De Sutter, B. 2000. Compiler techniques for code compaction. ACM Trans. Program. Lang. Syst. 22, 2 (Mar. 2000), 378–415. Wikipedia revision 1372508587, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1372508587
Cite this reference
MLA "Debray, S. K., Evans, W., Muth, R., and De Sutter, B. 2000. Compiler techniques for code compaction. ACM Trans. Program. Lang. Syst. 22, 2 (Mar. 2000), 378–415. Wikipedia revision 1372508587, retrieved 2026-11-18." Debray, S. 2026-11-17. http://doi.acm.org/10.1145/349214.349233. Accessed 24 November 2026.
Chicago "Debray, S. K., Evans, W., Muth, R., and De Sutter, B. 2000. Compiler techniques for code compaction. ACM Trans. Program. Lang. Syst. 22, 2 (Mar. 2000), 378–415. Wikipedia revision 1372508587, retrieved 2026-11-18." Debray, S. 2026-11-17. http://doi.acm.org/10.1145/349214.349233.
APA Debray, S. (2026). Debray, S. K., Evans, W., Muth, R., and De Sutter, B. 2000. Compiler techniques for code compaction. ACM Trans. Program. Lang. Syst. 22, 2 (Mar. 2000), 378–415. Wikipedia revision 1372508587, retrieved 2026-11-18. Retrieved November 24, 2026, from http://doi.acm.org/10.1145/349214.349233
Cite this article
MLA
"Redundant code." encyclopegia.org, 2026, https://encyclopegia.org/wiki/redundant-code. Accessed 24 November 2026.
Chicago
"Redundant code." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/redundant-code.
APA
encyclopegia.org. (2026). Redundant code. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/redundant-code
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON