D 2025-06-18T14:08:38.808
J icomment Appreciate\sthe\swarning\sbut\sI\sam\sindeed\saware\sof\sthe\sloading\sand\scaching\smechanism\sfor\sencodings.\sHowever,\snote\sthat\r\n\r\n*\sThe\ssuccess\scase\sdoes\sin\sfact\scall\s`Tcl_FreeEncoding`\sbut\sthe\serror\scase\sdoes\snot.\sThis\sinconsistency\sdoes\snot\smake\ssense\sif\sthe\sgoal\sis\sto\skeep\sencodings\sin\smemory.\r\n\r\n*\sThe\sfunctions\sin\squestion\sactually\suse\s`Tcl_GetEncodingFromObj`\swhich\sin\seffect\sadds\san\sextra\sreference\scount\sfor\sexactly\sthat\sreason.\sEven\swith\sa\s`Tcl_FreeEncoding`\sit\swill\sstay\sin\smemory\suntil\sthe\scaching\s`Tcl_Obj`\sis\sfreed\sor\sshimmered.\sSo\sfor\sinstance\swhen\sthe\sencoding\sname\sis\swithin\sa\sproc,\sit\swill\seffectively\skeep\sin\sthe\sencoding\sin\smemory\sas\slong\sas\sthe\sproc's\sbytecode\sexists.\r\n\r\n*\sAs\san\saside,\sthere\sis\sa\snon-trivial\samount\sof\scode\sthat\sdeals\swith\scaching\sof\sencoding\swith\sa\sshared\stable\sand\smutex\saccess.\sSo\sI\spresume\sat\ssome\spoint\sit\swas\sthought\sto\sbe\simportant\sto\sdiscard\sencoding\stables.\sI\sam\snot\ssure\swhat\swas\sconsidered\sa\slot\sof\smemory\sthree\sdecades\sago\sis\strue\sanymore\sand\sat\ssome\spoint\sit\smight\sbe\sworth\slooking\sat\snever\sreleasing\sloaded\sencodings,\sthereby\sboth\ssimplifying\sthe\scode\sand\smore\sefficient\sencoding\soperations\sby\savoiding\sthe\slocks\sand\scache\sflushes.
J login apnadkarni
J mimetype text/x-markdown
K e8b18d7b1fbe160a09d9d7dad382a3d150b41c87
U apnadkarni
Z 56fbdc9fa7f45895cd88208bbd18d866