Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3a41e88bc9d0239f80eb60ed296717557dc57245
Ticket: 218246ffffffffffffffffffffffffffffffffff
Enhancement for [eval] execution speed
User & Date: nobody on 2000-10-26 00:55:01
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2820 RFE
    Version: 8.2
    SubmitDate: '1999-09-17'
    LastModified: '1999-12-09'
    Severity: LOW
    Status: Closed
    Submitter: techsupp
    ChangedBy: hobbs
    RelatedBugIDs: 2257
    OS: Solaris
    OSVersion: 2.7
    Machine: Other
    FixedDate: '2000-10-25'
    ClosedDate: '1999-12-09'
    
    
    Name:
    
    Donal Fellows
    
    
    
    Comments:
    
    The patch I supply fixes this in a way that makes an improvement where
    
        it is safe to do so, and otherwise preserves existing behaviour.  It
    
        breaks no existing script (assuming the correct implementation of
    
        Tcl_EvalObjv() that is) and has almost no effect on performance outside
    
        its specific domain of applicability (it detects pure lists - those
    
        without a potentially dangerous string version - and uses Tcl_EvalObjv
    
        to execute them instead of the main part of Tcl_EvalObj.)
    
    
    
    DesiredBehavior:
    
    The standard version of Tcl_EvalObj does not treat a pure list
    
        specially, despite the fact that you can make the guarantee that the
    
        effect of:
    
              eval [list $var1 $var2 ... $varN]
    
        is precisely the same as:
    
              $var1 $var2 ... $varN
    
        whatever the contents of the variables $var1, $var2, ... $varN
    
        
    
        I want this inefficiency removed/reduced.  It makes a particularly big
    
        difference when you start to throw around lists with 10k elements in
    
        recursive calls through OO code...
    
    
    
    Patch:
    
    *** /home-local/rainbow/tcl8.2.0/generic/tclBasic.cSat May 15 00:16:54 1999
    
    --- tclBasic.cFri Sep 17 10:18:41 1999
    
    ***************
    
    *** 2561,2566 ****
    
    --- 2561,2583 ----
    
      return result;
    
          }
    
      
    
    +     /*
    
    +      * Check to see if we have a pure list (no string version.)  If so,
    
    +      * we can safely use Tcl_EvalObjv instead and get an appreciable
    
    +      * improvement in execution speed.  This is because it allows us to
    
    +      * avoid a setFromAny step that would just pack everything into a
    
    +      * string and back out again.
    
    +      */
    
    +     if (codePtr->typePtr == &tclListType && /* is a list... */
    
    + codePtr->bytes == NULL /* ...without a string version */) {
    
    +         register List *listRepPtr =
    
    +     (List *)codePtr->internalRep.otherValuePtr;
    
    +         result = Tcl_EvalObjv(interp, listRepPtr->elemCount,
    
    +       listRepPtr->elements, flags);
    
    + Tcl_DecrRefCount(codePtr);
    
    + return result;
    
    +     }
    
    + 
    
          savedVarFramePtr = iPtr->varFramePtr;
    
          if (flags & TCL_EVAL_GLOBAL) {
    
      iPtr->varFramePtr = NULL;
    
    
    
    PatchFiles:
    
    tclBasic.c
    
    
    
    
    
    This code is an incorrect patch (can't compile when patched in,
    and when fixed, the tests start breaking).  This is possibly an
    interesting optimization, but a patch has to pass the test suite. 
    -- 12/09/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "10. Objects"
  10. title changed to: "Enhancement for [eval] execution speed"
  11. type changed to: "Bug"