Ticket UUID: | 1352382 | |||
Title: | Patch: efficiency saving in Tcl_CreateNamespace | |||
Type: | Patch | Version: | None | |
Submitter: | nobody | Created on: | 2005-11-09 17:09:14 | |
Subsystem: | 21. [namespace] | Assigned To: | dkf | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2006-08-11 21:37:08 | |
Resolution: | Fixed | Closed By: | dkf | |
Closed on: | 2006-08-11 13:50:42 | |||
Description: |
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) | |||
User Comments: |
afredd added on 2006-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), nobody added on 2005-11-10 00:09:17: File Added - 155584: tclNamesp.c.patch |
Attachments:
- tclNamesp.c.patch [download] added by nobody on 2005-11-10 00:09:17. [details]