Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-08-11
21:37 • Ticket [1352382fff] Patch: efficiency saving in Tcl_CreateNamespace status s... artifact: 56841424f9 user: afredd
20:50 • Closed ticket [1352382fff]. artifact: 9b790c7550 user: dkf
2005-11-28
16:36 • Ticket [1352382fff]: 2 changes artifact: 0f9bce3b89 user: dkf
2005-11-10
00:09 • Add attachment tclNamesp.c.patch to ticket [1352382fffffffff|1352382fff... artifact: f82c4e63f4 user: nobody
00:09 • Ticket [1352382fff] Patch: efficiency saving in Tcl_CreateNamespace status s... artifact: 71808a7723 user: nobody
2005-11-09
17:09 • New ticket [1352382fff]. artifact: 2b37b30b61 user: nobody

Patch: efficiency saving in Tcl_CreateNamespace

Closed / Fixed1352382fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 20 years ago
Descriptionplain2005-11-09 17:09:14
The code building the fully qualified namespace name in 
Tcl_CreateNamespace unnecesarily copies buffer1 and 
buffer2 back and forth. By using Tcl_DString pointers, 
you can swap pointers instead of copying one buffer to 
the other. This saves a call to TclDStringSetLength & 
one to Tcl_DStringAppend. Also the strlen(name) can be 
avoided as we have the DString's length.
Patch also includes some other minor efficiency 
changes.

(the patch is against 8.5a3)
nobodyplain2005-11-10 00:09:17
File Added - 155584: tclNamesp.c.patch
dkf Ticket [1352382fff]: 2 changes [History diff]2005-11-28 16:36:49
dkf Closed ticket [1352382fff]. [History diff]2006-08-11 20:50:42
afreddplain2006-08-11 21:37:08
Logged In: YES 
user_id=1386588

(afredd)
It looks like a line of code got lost from the patch
in 1.96: the "buffPtr" DString needs to be cleared
before it is used each time. Currently it works for
two part namespaces eg. "::tcl::mathfunc", but will
generate a bad name if there are more parts.
This will fix it:

--- tclNamesp.c-orig    2006-08-11 15:28:55.203125000 +0100
+++ tclNamesp.c 2006-08-11 15:29:44.890625000 +0100
@@ -854,6 +854,7 @@
        if (ancestorPtr != globalNsPtr) {
            register Tcl_DString *tempPtr = namePtr;

+           Tcl_DStringSetLength(buffPtr, 0);
            Tcl_DStringAppend(buffPtr, "::", 2);
            Tcl_DStringAppend(buffPtr, ancestorPtr->name, -
1);
            Tcl_DStringAppend(buffPtr, Tcl_DStringValue
(namePtr),
Log in (anonymous is fine) to add a comment.

Attachments: