Performance: prefer lset over lreplace for modifying list values.
When a list element is modified, lset does it "in place", modifying the
variable itself, while lreplace works with values and returns a second copy
of the list with the modified elements, creating some unnecessary overhead.
On my local tests, this particular operation was around 30% faster.
More details:
http://wiki.tcl.tk/1485 and
http://wiki.tcl.tk/2556