Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0b32bbd550e4e859b7c867a1e31d2e6bd517e88a
Ticket: 465811ffffffffffffffffffffffffffffffffff
Optimize if/while/... during compilation
User & Date: andreas_kupries on 2001-09-27 20:50:54
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    This is possibly not a feature request but a 
    performance bug /
    enhancement.
    
    The control commands [if], [while] and [for] currently 
    do not check
    their expression arguments for static strings and 
    constant
    expressions. This means that for example
    
    if {0} {
    bla
    }
    
    is compiled into bytecode despite the fact that the 
    code will not be
    executed, ever.
    
    I propose that the compile procedures for the 
    aformentioned commands
    are extended to detect simple constant expressions and 
    to react
    accordingly. I.e. not to compile the if/while/for 
    statement at all or
    only partially and to compile only the sub-scripts 
    which are reachable
    for the constant expression.
    
    This enhancement is along the lines of the 
    optimization for [proc
    {args} {}], but should present less problems with 
    recompilation as no
    commands are implicitly added or removed from the 
    interp. It does
    present a new set of challenges if we want to go 
    beyond the detection
    of simple constant expressions to the detection of (0 
    && ...) etc.
    
    Note: This is easier for logical expressions as they 
    are defined to
    have shortcircuit evaluation and thus present less 
    problems with
    regard to variable tracing.
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "andreas_kupries"
  9. subsystem changed to: "47. Bytecode Compiler"
  10. title changed to: "Optimize if/while/... during compilation"
  11. type changed to: "RFE"