Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2000-10-26
08:17 • Closed ticket [218246ffff]: Enhancement for eval execution speed plus 4 ot... artifact: 40281a18f0 user: welch
00:55 • New ticket [218246ffff]. artifact: 3a41e88bc9 user: nobody

Enhancement for [eval] execution speed

Closed / Fixed218246ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:55:01
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
welch Closed ticket [218246ffff]. [History diff]2000-10-26 08:17:55
Log in (anonymous is fine) to add a comment.