summaryrefslogtreecommitdiffstats
path: root/library/msgcat
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-02-27 15:58:23 (GMT)
committersebres <sebres@users.sourceforge.net>2024-02-27 15:58:23 (GMT)
commit246997468102ec3fc2d1a205df911d1624fee20b (patch)
treec75b4502c6e703a0d6d1552c0d689bd2d5faa2ae /library/msgcat
parente4c5dbbeada1c721698d68ec85c03e5bfade1592 (diff)
downloadtcl-246997468102ec3fc2d1a205df911d1624fee20b.zip
tcl-246997468102ec3fc2d1a205df911d1624fee20b.tar.gz
tcl-246997468102ec3fc2d1a205df911d1624fee20b.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)
Diffstat (limited to 'library/msgcat')
-rw-r--r--library/msgcat/msgcat.tcl45
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
}
}
}