Overview
| Artifact ID: | 0970544aff38d6fc6dc40d394d11d97b63a17535 |
|---|---|
| Ticket: | 219109ffffffffffffffffffffffffffffffffff
string repeat speedup by pre-allocating TclObj |
| User & Date: | nobody on 2000-10-26 01:10:55 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 6018 RFE Version: 8.3.1 SubmitDate: '2000-07-18' LastModified: '2000-09-26' Severity: LOW Status: Released Submitter: techsupp ChangedBy: hobbs OS: All FixedDate: '2000-09-26' FixedInVersion: 8.4a2 ClosedDate: '2000-10-25' Name: Bob Techentin Comments: It would probably be even more efficient to copy the guts of AppendUtfToUtfRep (in tclStringObj.c) but that might be reaching down to too low a level for this command. I tried it and got 75% speedup, but it core dumps in the corner cases in the test suite. DesiredBehavior: The new [string repeat] command will iteratively call Tcl_AppendToObj() to build up a repeating string. This causes several calls to reallocate more memory for the result object. It is more efficient to call Tcl_SetObjLength() once before the appends, so that it is not necessary to reallocate memory while building up the string. This results in about a 20% speedup on my system, and reduces the chances of the automatic allocator using too much memory (it doubles the object length each time). Patch: *** tclCmdMZ.c.orig Mon Jul 17 14:51:48 2000 --- tclCmdMZ.c Mon Jul 17 15:26:56 2000 *************** *** 1823,1828 **** --- 1823,1829 ---- string1 = Tcl_GetStringFromObj(objv[2], &length1); if (length1 > 0) { + Tcl_SetObjLength(resultPtr, count*length1); for (index = 0; index < count; index++) { Tcl_AppendToObj(resultPtr, string1, length1); } PatchFiles: tclCmdMZ.c That simple fix unfortunately doesn't have the desired effect, but I've changed around 8.4a2 to use ckalloc directly for the same effect. -- 09/26/2000 hobbs - foundin changed to: "obsolete: 8.3.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "81. Bundled Packages"
- title changed to: "string repeat speedup by pre-allocating TclObj"
- type changed to: "RFE"