Skip to content
Tcl Source Code View Ticket
Login

View Ticket

caching fully qualified cmd names

Closed / Accepted456668ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-08-29 21:48:03
The enclosed patch allows cached fully qualified
command names to be usable from different namespaces
within the same interpreter. 

This costs next to nothing for normal scripts, and may
be valuable for OO apps that pass around command names
in variables ("this").
msoferplain2001-08-30 04:48:04
File Added - 10148: cmdName.patch
hobbsplain2001-08-30 06:50:04
Logged In: YES 
user_id=72656

can you elaborate a bit more on a use case?
Perhaps something that could be added to tclbench.
msoferplain2001-08-30 07:41:11
Logged In: YES 
user_id=148712

The speedup can be noticeable; witness 

[mig@mini unix]$ cat /tmp/testfile 
proc a {} {return 1}

namespace eval n1 {
    proc b {scr} {$scr}
}

proc c {scr} {
    n1::b $scr
    $scr
}

proc d {} {
    append res [time {c a} 10000]\n
    append res [time {c ::a} 10000]
}

puts [info patch]
puts [d]


[mig@mini unix]$ ./tclsh /tmp/testfile 
8.4a4
12 microseconds per iteration
8 microseconds per iteration
[mig@mini unix]$ /CVS/tcl_SF_clean/unix/tclsh /tmp/testfile 
8.4a4
13 microseconds per iteration
12 microseconds per iteration
[mig@mini unix]$ tclsh /tmp/testfile 
8.3.3
15 microseconds per iteration
15 microseconds per iteration

Jeff: does this patch look OK to you?
hobbs Ticket [456668ffff]: 1 change [History diff]2001-08-30 08:08:10
hobbsplain2001-08-30 08:08:11
Logged In: YES 
user_id=72656

The patch passes all tests, and there is a notable 
improvement, so I say go ahead and commit it.  Please 
change it first to not use the { } frame instantiation 
trick in C to create new vars.
msoferplain2001-08-30 19:11:02
File Deleted - 10148: 



File Added - 10175: cmdName.patch

Logged In: YES 
user_id=148712

Patch adapted and committed.
msofer Closed ticket [456668ffff]. [History diff]2001-08-30 19:11:34
msoferplain2001-09-06 03:18:36
Logged In: YES 
user_id=148712

See also the companion patch #458872 that does the same
caching for namespace names.
Log in (anonymous is fine) to add a comment.

Attachments: