Am 22.06.22 um 18:48 schrieb aotto1968:
Instead of asking, which one is faster, you should benchmark it. There
is the time command in the core (and, in newer cores, also the timerate command)
Question it is efficient to keep the code as it is **OR** to add a
global variable with a *non-changing* global value
NEW
set myRX "${::librx}(\\w+)$"
I would expect that there is no big difference. The largest effort is
Hi,
this is a piece of code to delete a *const* prefix (librx) from a string (str)
OLD:
proc pCleanLibRx { str } {
regsub "${::librx}(\\w+)$" $str {\1}
}
as you see the string is *not* static by definition only by *logic*
Question it is efficient to keep the code as it is **OR** to add a
global variable with a *non-changing* global value
NEW
set myRX "${::librx}(\\w+)$"
Question it is efficient to keep the code as it is **OR** to add a
global variable with a *non-changing* global value
NEW
set myRX "${::librx}(\\w+)$"
I would expect that there is no big difference. The largest effort is
Indeed, for a dynamic string like this, the global variable should be
faster. Still, the RE engine caches not only the conmpiled expressino in
the intrep, but also the most recently used expression strings in order
to deal with this problem of dynamically constructed const strings. That
is special to regexp and does not hold for any other shimmering issue.
Christian
Question it is efficient to keep the code as it is **OR** to add a
global variable with a *non-changing* global value
NEW
set myRX "${::librx}(\\w+)$"
I would expect that there is no big difference. The largest effort is
Indeed, for a dynamic string like this, the global variable should be
faster. Still, the RE engine caches not only the conmpiled expressino
in the intrep, but also the most recently used expression strings in
order to deal with this problem of dynamically constructed const
strings. That is special to regexp and does not hold for any other
shimmering issue.
Christian
thanks for the answer… I think a lot of performance is lost in tcl
because of the *const-by-logic* issue.
...
this is a piece of code to delete a *const* prefix (librx) from a string (str)
OLD:
proc pCleanLibRx { str } {
regsub "${::librx}(\\w+)$" $str {\1}
}
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 165:45:27 |
| Calls: | 12,096 |
| Calls today: | 4 |
| Files: | 15,001 |
| Messages: | 6,517,807 |