Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-08-22
08:11 • Ticket [403709ffff] Improve speed of split $string "" (bug #131523)<... artifact: be801e86d7 user: dkf
2001-02-16
16:27 • Closed ticket [403709ffff]. artifact: 0b928be340 user: dkf
16:22 • ticket [403709ffff]. artifact: b0a88feb90 user: dkf
00:12 • Ticket [403709ffff]: 4 changes artifact: 3a1716688d user: dgp
2001-02-15
23:21 • Ticket [403709ffff]: 5 changes artifact: 151c297472 user: dkf
2001-02-13
05:39 • Ticket [403709ffff]: 4 changes artifact: d687a4cfe4 user: dgp
00:15 • Ticket [403709ffff]: 4 changes artifact: 2e4d9bec86 user: dgp
2001-02-12
16:52 • Ticket [403709ffff]: 4 changes artifact: e2631b4ead user: dkf
13:40 • Ticket [403709ffff]: 4 changes artifact: 96a53ca760 user: andreas_kupries
2001-02-10
04:08 • Ticket [403709ffff]: 4 changes artifact: 7df500a0d5 user: dgp
2001-02-09
18:31 • Ticket [403709ffff]: 4 changes artifact: ec50d6ff51 user: dkf
18:30 • Add attachment None to ticket [403709ffff] artifact: d48cf63452 user: dkf
11:30 • New ticket [403709ffff] Improve speed of split $string "" (bug #1315... artifact: 5a93a39fd5 user: dkf

Improve speed of [split $string ""] (bug #131523)

Closed / Accepted403709ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 10 years ago
Descriptionplain2001-02-09 11:30:17
This patch makes splitting a string into single characters use only as many objects as there are distinct characters in the input string.  It boosts performance in the short string case, which is nice, but turns the long string case from intractable into quite feasable.  :^)

All tests in the current CVS HEAD are passed with this patch applied.
dkfplain2001-02-09 18:31:13
Please review; I think this one is OK (it certainly seems to work for me) but it is nice to have someone else give it the once over before applying it...
dgpplain2001-02-10 04:08:53
It applies, builds, and passes 'make test' for me on
a 64-bit Alpha.

I'm a bit uneasy by all the typecasting

Tcl_UniChar -> int -> (char *)

What are they for and are you confident they will be OK
always and everywhere?

Other than that, the variable names hent and intch don't
seem to fit with the core traditions.  Use of hPtr or
hashEntry is more common.
andreas_kupriesplain2001-02-12 13:40:33
Tcl_UniChar -> int -> (char *) 

The first is safe, AFAIK, because IIRC Tcl_UniChar represents UTF16 coding of characters which is 2 bytes at most. And int is 2 bytes at least. The (char*) should be read is (void*). Tcl_CreateHashTable has a very generic interface to keys, because of the various possible key-types. As the hash is created with one-word-keys an (int*) is ok, even in the guise of a (char*).

I agree that we should change the variable names to match the core style.
dkfplain2001-02-12 16:52:55
Patch Code - Modified - New Version

The (char *) is correct as that because that is how hash tables configured with TCL_ONE_WORD_KEYS are used (as documented on the manual page.)  The assumption that UNICODE characters are sensibly castable to int is pretty good; it certainly works for UCS-16 and will actually be good in practise (even on 64-bit architectures as deployed) up to UCS-32 which is, incidentally, not supported by the rest of the core anyway.  :^)

Variable names in patch have been modified to match core naming scheme.  My fault for naming them according to the scheme which I use in my own programs instead...
dgpplain2001-02-13 00:15:46
But why the intermediate type of int ?  Why not a direct
cast:

Tcl_UniChar -> (char *)
dgpplain2001-02-13 05:39:03
Note some more followups posted directly to the
tcl-bugs mailing list:

http://www.geocrawler.com/lists/3/SourceForge/7374/0/5149633/
http://www.geocrawler.com/lists/3/SourceForge/7374/0/5151315/
dkfplain2001-02-15 23:21:16
Patch Code - Modified - New Version

Hopefully those strange 64-bit beasties will like this version better.
dgpplain2001-02-16 00:12:54
Patch Code - Modified - New Version

I modified the date in the ChangeLog entry, and made
a change to one of the comments ("integral type" rather
than "numeric type").

Looks like it's ready to go now.  Make it so.  Nice work.
dkf ticket [403709ffff]. [History diff]2001-02-16 16:22:47
dkf Closed ticket [403709ffff]. [History diff]2001-02-16 16:27:17
dkf Ticket [403709ffff]: 7 changes [History diff]2016-08-22 08:11:46
Log in (anonymous is fine) to add a comment.

Attachments: