Tcl Source Code

View Ticket
Login
Ticket UUID: 456668
Title: caching fully qualified cmd names
Type: Patch Version: None
Submitter: msofer Created on: 2001-08-29 21:48:03
Subsystem: 47. Bytecode Compiler Assigned To: msofer
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-09-06 03:18:36
Resolution: Accepted Closed By: msofer
    Closed on: 2001-09-05 20:18:36
Description:
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").
User Comments: msofer added on 2001-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.

msofer added on 2001-08-30 19:11:02:

File Deleted - 10148: 



File Added - 10175: cmdName.patch

Logged In: YES 
user_id=148712

Patch adapted and committed.

hobbs added on 2001-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.

msofer added on 2001-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 added on 2001-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.

msofer added on 2001-08-30 04:48:04:

File Added - 10148: cmdName.patch

Attachments: