Artifacts Associated With Ticket 1246897
Ticket change [f5add77efe] (rid 130155) by nobody on 2005-07-28 16:11:31:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Minor optimisation: there are a few calls to Tcl_DStringAppend with fixed strings, but give a length of -1. Replacing the -1 with the actual length (as is done in other places) would save a strlen. eg. tclConfig.c:141: Tcl_DStringAppend (&cmdName, "::", -1); tclConfig.c:161: Tcl_DStringAppend (&cmdName, "::pkgconfig", -1); tclInterp.c:433: Tcl_DStringAppend(&script, "lsearch - exact", -1); tclInterp.c:437: Tcl_DStringAppend(&script, " [file join [info library] encoding]", -1); tclInterp.c:450: Tcl_DStringAppend(&script, "file join [info library] encoding", -1); tclUtil.c:1856:Tcl_DStringAppend(dsPtr, " {", -1); tclUtil.c:1858:Tcl_DStringAppend(dsPtr, "{", -1); tclUtil.c:1885: Tcl_DStringAppend(dsPtr, "}", -1); There are also some where the string being copied is a Tcl_DString, so we could use the corresponding Tcl_DStringLength instead of -1; again saving a strlen. eg. tclLoad.c:349:Tcl_DStringAppend(&initName, Tcl_DStringValue(&pkgName), -1); tclLoad.c:351:Tcl_DStringAppend (&safeInitName, Tcl_DStringValue(&pkgName), -1); tclLoad.c:353: Tcl_DStringAppend(&unloadName, Tcl_DStringValue(&pkgName), -1); tclLoad.c:355: Tcl_DStringAppend (&safeUnloadName, Tcl_DStringValue(&pkgName), -1); tclNamesp.c:823:Tcl_DStringAppend(&buffer1, Tcl_DStringValue(&buffer2), -1); tclNamesp.c:826:Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&buffer1), -1); (which makes me wonder if the Right Thing is done if any of the above contain embedded NULs in them, as the strlen will give the 'incorrect' length.). Final point, wouldn't the copy loop in Tcl_DStringAppend be quicker as a memcpy and not as a character by character copy in the for loop. I've no empirical evidence, just the (perhaps incorrect!) assumption that the C library's memcpy is quicker than the corresponding for loop. Cheers! - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "None"
- title initialized to: "Minor optimsations for Tcl_DStringAppend usage."
- type initialized to: "Patch"
Ticket change [66b75609dc] (rid 102765) by dkf on 2005-07-28 23:25:57:
- assignee changed to: "dgp"
- priority changed to: "4"
Ticket change [d509efaf11] (rid 123548) by dgp on 2005-07-29 04:32:13:
- icomment:
Logged In: YES user_id=80530 there's no patch here?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [1b89fa6e45] (rid 123170) by dgp on 2005-07-29 05:04:06:
- icomment:
Logged In: YES user_id=80530 The docs aren't explicit about it (perhaps because they are so old), but I don't believe the Tcl_DString* routines were ever intended to support embedded NUL bytes within the dynamic strings. The comment on the "length" field of the Tcl_DString struct (in tcl.h) reads: Number of non-NULL characters in the string That said, it's clear that callers of Tcl_DStringAppend() and Tcl_DStringSetLength() could leave NUL bytes within the "length" of the string. Wise or not, the Tcl_DString* routines are fairly low level and have a long history of exposing that capability. If it gets too troubling, just make use of Tcl_Obj's for your dynamically sized string values.
- login: "dgp"
- mimetype: "text/plain"
- priority changed to: "3 Low"
- username: "dgp"
- icomment:
Ticket change [d2fa4dce85] (rid 113615) by dkf on 2005-07-29 15:56:11:
- icomment:
Logged In: YES user_id=79902 The encoding subsystem relies on the fact that DStrings can hold NUL bytes. The DString system serves multiple purposes, some of which are obsolete these days. It is both a way of having safely managed buffers and a mechanism for doing some string manipulations that was heavily used back in Tcl 7.* (and before?) but which has been largely superceded for this latter purpose these days by the Tcl_Obj system. I'm fairly strongly inclined to leave things as they are unless the code in question is on some performance critical path: easier maintenance beats shaving a few nanoseconds from a location where it will get swamped by some syscall...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [8186dbb15e] (rid 117054) by dgp on 2005-08-13 09:12:27:
- icomment:
Logged In: YES user_id=80530 The fixed string arguments should continue to be paired with -1 arguments, for ease of maintenance when the fixed string might be changed. When copying DStrings, I agree we'd be better off passing in the DStringLength rather than -1. The memcpy seems reasonable to me. I'd happily accept a patch along those lines. Separate patches for both 8.5 and 8.4 lines would be even better. Thanks.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Pending"
- username: "dgp"
- icomment:
Ticket change [525cd5395c] (rid 126305) by dgp on 2005-08-13 09:12:28:
- closedate changed to: "2005-08-13T02:12:28"
- closer changed to: "dgp"
Ticket change [d34bdd5fd5] (rid 123268) by sf-robot on 2005-08-27 09:20:35:
- closedate changed to: "2005-08-27T02:20:35"
- closer changed to: "sf-robot"
- icomment:
Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
- login: "sf-robot"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "sf-robot"