diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-02-28 10:00:47 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-02-28 10:00:47 (GMT) |
| commit | fe46862527d1efecb1f4b3e448a0df96b98a9995 (patch) | |
| tree | 6d9e0b400b7d5104c40e96f341f4ffccc996eb82 | |
| parent | c6a3c1f1478925bbb0bc39fe3d9efda584a899d3 (diff) | |
| parent | 0f3a185fdd54c9846b2f8e7289aa0a85fdf555d4 (diff) | |
| download | tcl-fe46862527d1efecb1f4b3e448a0df96b98a9995.zip tcl-fe46862527d1efecb1f4b3e448a0df96b98a9995.tar.gz tcl-fe46862527d1efecb1f4b3e448a0df96b98a9995.tar.bz2 | |
fixes [e02798626dfbcd7b] - close regression introduced by TIP#490 causing too slow eval of mc command for non-class namespaces (speed-up msgcat and clock packages)
| -rw-r--r-- | library/clock.tcl | 2 | ||||
| -rw-r--r-- | library/msgcat/msgcat.tcl | 45 |
2 files changed, 26 insertions, 21 deletions
diff --git a/library/clock.tcl b/library/clock.tcl index 706bc98..9d41b80 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -60,7 +60,7 @@ namespace eval ::tcl::clock { namespace import ::msgcat::mcload namespace import ::msgcat::mclocale - namespace import ::msgcat::mc + proc mc {args} { tailcall ::msgcat::mcn [namespace current] {*}$args } namespace import ::msgcat::mcpackagelocale } diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index fa21685..589da7a 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -1220,27 +1220,32 @@ proc msgcat::mcutil::ConvertLocale {value} { # - called from an class defined oo object # - called from a classless oo object proc ::msgcat::PackageNamespaceGet {} { - uplevel 2 { - # Check self namespace to determine environment - switch -exact -- [namespace which self] { - {::oo::define::self} { - # We are within a class definition - return [namespace qualifiers [self]] - } - {::oo::Helpers::self} { - # We are within an object - set Class [info object class [self]] - # Check for classless defined object - if {$Class eq {::oo::object}} { - return [namespace qualifiers [self]] - } - # Class defined object - return [namespace qualifiers $Class] - } - default { - # Not in object environment - return [namespace current] + set ns [uplevel 2 { namespace current }] + + if {![string match {::oo::*} $ns]} { + # Not in object environment + return $ns + } + + # Check self namespace to determine environment + switch -exact -- [uplevel 2 { namespace which -command self }] { + {::oo::define::self} { + # We are within a class definition + return [namespace qualifiers [uplevel 2 { self }]] + } + {::oo::Helpers::self} { + # We are within an object + set Class [info object class [uplevel 2 { self }]] + # Check for classless defined object + if {$Class eq {::oo::object}} { + return [namespace qualifiers [uplevel 2 { self }]] } + # Class defined object + return [namespace qualifiers $Class] + } + default { + # Not in object environment + return $ns } } } |
