Bwidget Source Code
View Ticket
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 393b67ab196a6fa7e8d2ecdc51bc6ca9c24da418
Title: Unnecessary temporary widget creation
Type: Patch Version: 1.9.7
Submitter: anonymous Created on: 2014-05-14 09:53:58
Subsystem: (unused) Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2014-05-21 07:16:50
Resolution: Accepted Closed By: oehhar
    Closed on: 2014-05-21 07:16:50
From: Adrián Medraño Calvo <[email protected]>

Not long ago, my colleage Wolfgang S. Kechel sent a patch removing unneeded
creation of ".ericFoo##" widget. This continues the job by removing another
instance of the issue.

The temporary widget was being created with the purpose of retrieving the
default values, but this functionality is already encapsulated by the
[_get_tkwidget_options] procedure. As such, there is no need to create an
additional temporary widget. As the code was already invoking
[_get_tkwidget_options], its result is simply reused.
 bwidget-1.9.7/widget.tcl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bwidget-1.9.7/widget.tcl b/bwidget-1.9.7/widget.tcl
index 98c6852..d4748f3 100755
--- a/bwidget-1.9.7/widget.tcl
+++ b/bwidget-1.9.7/widget.tcl
@@ -372,24 +372,24 @@ proc Widget::declare { class optlist } {
         # retreive default value for TkResource
         if { [string equal $type "TkResource"] } {
             set tkwidget [lindex $arg 0]
-	    set foo [$tkwidget ".ericFoo##"]
             set realopt  [lindex $arg 1]
             if { ![string length $realopt] } {
                 set realopt $option
             set tkoptions [_get_tkwidget_options $tkwidget]
+            set ind [lsearch $tkoptions [list $realopt *]]
+            set optdesc [lindex $tkoptions $ind];
             if { ![string length $value] } {
                 # We initialize default value
-		set ind [lsearch $tkoptions [list $realopt *]]
-                set value [lindex [lindex $tkoptions $ind] end]
+                set value [lindex $optdesc end]
 	    set optionDbName ".[lindex [_configure_option $option ""] 0]"
 	    option add *${class}${optionDbName} $value widgetDefault
 	    set exports($option) $optionDbName
             set classopt($option) [list TkResource $value $ro \
 		    [list $tkwidget $realopt]]
-	    set optionClass($option) [lindex [$foo configure $realopt] 1]
-	    ::destroy $foo
+	    set optionClass($option) [lindex $optdesc 1]
User Comments: oehhar added on 2014-05-21 07:16:50:

Committed by checkin [5a776453e1].

I would love to be able to test it but I just trust it is ok.

I removed spanish acentuation characters in your name in changelog. Sorry, I want to keep it 7 bits. Pardon pour el informatica si tonto ;-)

Thank you, Harald