Janis Papanagnou
2024-10-25 04:46:05 UTC
For this command
typeset -i indents=$(( level * indent_factor )) ###
with two integer variables, 'level' and 'indent_factor', declared
I'm getting this nice warning message
warning: line 28: indents=$(( level * indent_factor ))
is slower than ((indents= level * indent_factor ))
I thought (to avoid the warning) I'd have to split the lines like
typeset -i indents
(( indents = level * indent_factor ))
but I noticed that we can also write
(( typeset -i indents = level * indent_factor ))
(I wasn't aware about the 'typeset' command possible in arithmetic
expressions.)
Though I wonder why Ksh doesn't silently optimize the '###' marked
code since Ksh optimizes so many less obvious and much more complex
things.
Janis
typeset -i indents=$(( level * indent_factor )) ###
with two integer variables, 'level' and 'indent_factor', declared
I'm getting this nice warning message
warning: line 28: indents=$(( level * indent_factor ))
is slower than ((indents= level * indent_factor ))
I thought (to avoid the warning) I'd have to split the lines like
typeset -i indents
(( indents = level * indent_factor ))
but I noticed that we can also write
(( typeset -i indents = level * indent_factor ))
(I wasn't aware about the 'typeset' command possible in arithmetic
expressions.)
Though I wonder why Ksh doesn't silently optimize the '###' marked
code since Ksh optimizes so many less obvious and much more complex
things.
Janis