diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-02-27 15:58:23 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-02-27 15:58:23 (GMT) |
| commit | eb58d1f40937d22c6b2e5ec394b6a6184c67b523 (patch) | |
| tree | c75b4502c6e703a0d6d1552c0d689bd2d5faa2ae | |
| parent | 208e868b60981ad970dca74d009df9ebfd2b56ff (diff) | |
| download | tcl-eb58d1f40937d22c6b2e5ec394b6a6184c67b523.zip tcl-eb58d1f40937d22c6b2e5ec394b6a6184c67b523.tar.gz tcl-eb58d1f40937d22c6b2e5ec394b6a6184c67b523.tar.bz2 | |
fixes [e02798626d]: close regression introduced by TIP#490 causing too slow eval of mc command for non-class namespaces (probably by shimmering of something NS-related across ::msgcat::PackageNamespaceGet)
| -rw-r--r-- | library/msgcat/msgcat.tcl | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index fa21685..0c7f515 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 {![regexp -- {^::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 } } } |
