In
computer science,
self-modifying code is
code that alters its own
instructions while it is
executing - usually to reduce the
instruction path length and improve
performance or simply to reduce otherwise repetitively similar code, thus simplifying maintenance. Self modification is an alternative to the method of "flag setting" and conditional program branching, used primarily to reduce the number of times a condition needs to be tested. The term is usually only applied to code where the self-modification is intentional, not in situations where code accidentally modifies itself due to an error such as a
buffer overflow.