| Ticket UUID: | 924097 | ||
| Title: | optimise {}-appends | ||
| Type: | RFE | Created on: | 2004-03-26 18:35:27 |
| Submitter: | msofer | Assigned to: | msofer |
| Subsystem: | 47. Bytecode Compiler | Severity: | |
| Priority: | 5 Medium | Last modified: | 2004-09-10 19:49:15 |
| Status: | Closed | Closed by: | msofer |
| Resolution: | Accepted | Closed on: | 2004-09-10 12:49:15 |
| Version: | None | ||
| Description: | ||||
When appending to a Tcl_Obj, check first if the obj to
be appended is {}. In that case, return the untouched
original obj - avoid computing it's stringRep or
invalidating it's internalRep.
With this in place, the inline version of
K $x [set x {}]
can be written
$x[set x {}]
for greater performance.
Remark that this optimisation can be done at run time,
and also at compile time if the obj to be appended is
known to be {}. The compile time opt is however rather
involved - in the example above it would be possible in
principle (as 'set' is compiled, a redefinition will
trigger a recompilation of the whole script), but not in
$x[unset x]
| ||||
| User Comments: | ||||
dgp added on 2004-03-27 02:06:48:
Logged In: YES user_id=80530 the compiletime optimization is probably not possible, without some guarantee that there will not be a write trace on x at run time. (which might raise an error, or set a different, non-empty value). dkf added on 2004-03-29 17:40:18:
Logged In: YES user_id=79902 Start by doing the runtime opt as that should be a safe peephole thing. Compile time optimisation is trickier because of the issues that DGP mentions, though I think there are ways round it. Those particular ideas of mine need more baking first though... msofer added on 2004-09-10 19:49:15:
Logged In: YES user_id=148712 Peephole optimisation to INST_CONCAT1 commited. | ||||
