Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d4436c8a92af1b66a0575e9856d84bcb0edf3590
Ticket: 903765ffffffffffffffffffffffffffffffffff
avoid quadratic parsing time
User & Date: dgp on 2004-02-24 22:07:40
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    It's been noted on the Wiki...
    
        http://wiki.tcl.tk/9585
    
    that the runtime of
    
        expr 1[string repeat +1 $N]
    
    is quadratic in $N.
    
    This is due to Tcl_ParseExpr().
    After each + is parsed in 
    ParseAddExpr(), a call is made
    to PrependSubExprTokens to
    shift the already parsed operands
    down the token array to make room
    for the operand token at the beginning.
    
    This means that $N times, $n tokens
    are copied (as $n grows from 1 to $N)
    just to get the parsing done -- quadratic
    complexity.
    
    Similar issues arise with other expressions
    that call PrependSubExprTokens.
    
    For most short expressions, this penalty
    hardly matters, but a more scalable parser
    would be nice.
    
  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: "dgp"
  9. subsystem changed to: "45. Parsing and Eval"
  10. title changed to: "avoid quadratic parsing time"
  11. type changed to: "RFE"