Artifacts Associated With Ticket 10545687da
Ticket change [6f7c202ff0] (rid 245150) by dgp on 2025-09-04 19:10:50:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Tcl_GetNumberFromObj() has already been written to make use of the extended Tcl_ObjType abstract list routines to efficiently reject non-singleton lists as non-numbers. I have a patch to re-order this processing, which is possible because all of Tcl's numeric types have implemented the abstract list routines so rejecting early is efficient enough to come first without worry about slowing down the accept results noticeably. Some comments are added to help later readers understand the logic.
- foundin initialized to: "9.0"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- private_contact initialized to: "8e2300e85be5dd1445b9666eb9429055951e33be"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "10. Objects"
- title initialized to:
Improve Tcl_GetNumberFromObj with abstract list interfaces
- type initialized to: "Bug"
Ticket change [9d56d700b9] (rid 245155) by dgp on 2025-09-04 19:12:51:
- icomment:
Branch bug-10545687da ready for review and merge.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [9ffc461106] (rid 245182) by jan.nijtmans on 2025-09-05 13:01:35:
- icomment:
Actually, I don't like this change. What is done here is speed-up the error-case, slowing down the most-common OK case, where the Tcl_Obj is already a double, int or bignum. It's only a few compare operations, not much at all, but I don't see much benefit on this change. Speed is more important for the OK case than for the error-case (which is already slow anyway), therefore I prefer the code as it was. Sorry! Adding comments, so people understand the logic is always good. Maybe we should comment here why checking for double/int/bignum is done first.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [be25ddce97] (rid 245183) by jan.nijtmans on 2025-09-05 13:05:21:
- icomment:
Another reason the lengthProc() shouldn't be called first: What if some extension implements an objtype which is implemented as a linked list. Then the lengthProc() of this type might be very costly. That's why lengthProc() should be called last, after all other (cheap) type checks.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [5920eddf8b] (rid 245184) by dgp on 2025-09-05 13:44:19:
- icomment:
I think if you reflect a little longer you will see that your second comment doesn't match how these facilities are used. I will look again to see what adaptations can take account of your first comment.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [a422c44717] (rid 245185) by griffin on 2025-09-05 13:52:40:
- icomment:
Not sure if making a choice based on potential bad actors implementing poorly designed abstract lists is wise. Then there's the coder that chooses to use GetNumber without having some reasonable assumption that it is a number. I think avoiding string creation whenever possible is as important as avoiding shimmering. What is needed is some test results that characterize the different approaches.
- login: "griffin"
- mimetype: "text/plain"
- icomment:
Ticket change [a76f7778a7] (rid 245193) by jan.nijtmans on 2025-09-05 15:13:17:
- icomment:
Note that there are 8 functions following the same concept: Tcl_GetNumberFromObj(), Tcl_GetLongFromObj(), Tcl_GetWideIntFromObj(), Tcl_GetWideUIntFromObj(), TclGetWideBitsFromObj(), GetBignumFromObj(), Tcl_GetDoubleFromObj() and Tcl_GetBoolFromObj(). All of them do this to prevent generating the string representation in as many situations as possible.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [1c4db6a439] (rid 245198) by dgp on 2025-09-05 19:58:46:
- icomment:
Revised code committed for further review. Now that you point out the other places dealing with similar tasks, I'll see whether there's a refactor opportunity.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [4b6f9df217] (rid 245199) by jan.nijtmans on 2025-09-06 10:15:54:
- icomment:
Even better: why not move the lengthProc protection into TclParseNumber(). Then all callers of TclParseNumber() can benefit from it
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [e8df6e42fe] (rid 245200) by jan.nijtmans on 2025-09-06 10:32:24:
- icomment:
Note that [0439e1e1a3|this] ticket is where this all originate from
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [963863b4e4] (rid 245209) by jan.nijtmans on 2025-09-07 10:15:53:
- icomment:
[eda10ad40c|this] is (starting) the refactoring I had in mind. Not finished yet (the same can be done in some more functions), but you can already review this part.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [276a7abacc] (rid 245252) by dgp on 2025-09-08 14:20:36:
- assignee changed to: "dgp"
- closedate changed to: "2460927.09764181"
- closer changed to: "dgp"
- icomment:
This has been overtaken by work on another ticket. Closing.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Out of Date"
- status changed to: "Closed"