From 246997468102ec3fc2d1a205df911d1624fee20b Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 27 Feb 2024 15:58:23 +0000 Subject: 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) --- library/msgcat/msgcat.tcl | 45 +++++++++++++++++++++++++-------------------- 1 file 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 } } } -- cgit v0.12 From 9c1f4a61846eb112bb60ab5dc446449cfefb9a25 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 27 Feb 2024 16:07:20 +0000 Subject: amend to [e02798626dfbcd7b]: speed-up ::tcl::clock::mc a little bit (uses msgcat::mcn internally instead of msgcat::mc) --- library/clock.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } -- cgit v0.12 From 8da27abc6cc3606297bca30466516c0f0c02a2c3 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 27 Feb 2024 18:21:33 +0000 Subject: small amend for better readability (no RE needed, faster utf prefix compare) --- library/msgcat/msgcat.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 0c7f515..589da7a 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -1222,7 +1222,7 @@ proc msgcat::mcutil::ConvertLocale {value} { proc ::msgcat::PackageNamespaceGet {} { set ns [uplevel 2 { namespace current }] - if {![regexp -- {^::oo::} $ns]} { + if {![string match {::oo::*} $ns]} { # Not in object environment return $ns } -- cgit v0.12