Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-09-08
02:57 • Ticket [1552883fff] msgcat dict usage status still Closed with 4 other cha... artifact: 9be916befb user: dkf
02:48 • Closed ticket [1552883fff]. artifact: fa63d83e5b user: dgp
2006-09-07
17:28 • Ticket [1552883fff]: 5 changes artifact: 54c9d7b959 user: dkf
2006-09-05
18:15 • New ticket [1552883fff]. artifact: d5c9208109 user: dgp

msgcat [dict] usage

Closed / Invalid1552883fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-09-05 18:15:28
Want [dict] expertise to
weigh in on this.  Considering
replacing:

  foreach {src dist} $pairs {
    dict set Msgs $locale $ns $src $dest
  }

with:

  dict set Msgs $locale $ns \
      [dict replace \
      [dict get $Msgs $locale $ns] \
      {expand}$pairs]

Any advice on whether that should
be expected to be an improvement?
Any need for [K]?

(Note that the use of {expand} will
force direct evaluation - no bytecode)
dkfplain2006-09-07 17:28:37
Logged In: YES 
user_id=79902

Is loading a message catalog a bottleneck? If not, anything
will do if it works.

Another suggested version:

  dict update Msgs $locale locale {
     dict update locale $ns map {
        set map [dict replace $map {expand}$pairs]
     }
  }

If performance is critical, measure the alternatives and use
the best one ([dict replace] is not bytecode compiled
anyway, and all other dict subcommands mentioned are.)
dgpplain2006-09-08 02:48:09
Logged In: YES 
user_id=80530


Looking into this some more,
it appears the original is
really best.  Whatever one
might save pushing the
[foreach] from Tcl into C,
one is certain to lose in
all the additional copying
of shared Tcl_Obj's that
[dict replace] and [dict update]
will require.  The original
appears to do a true update
in place.
dkfplain2006-09-08 02:57:45
Logged In: YES 
user_id=79902

While it is possible to do things to make the code more
efficient (á la [K]) I don't recommend it if there is no
clear performance gain, as they are messy and surprisingly
hard to maintain. Simple is Good!
Log in (anonymous is fine) to add a comment.