|
From: | Wolfgang Laun |
Subject: | Re: [bug-gawk] Does gawk optimize length(row) in for-loop? |
Date: | Sat, 25 Mar 2017 21:29:34 +0100 |
Hi, I have the following two code snippets. The first one takes the
length() out of the loop. I am wondering whether gawk does any
optimization for case 2 so that length() is only called once. Or
length() will be called multiple times in case 2?
# code snippet 1
nf = length(row)
for(i=dat_col; i<=nf; ++i) {
data[i] += row[i]
}
# code snippet 2
for(i=dat_col; i<=length(row); ++i) {
data[i] += row[i]
}
--
Regards,
Peng
[Prev in Thread] | Current Thread | [Next in Thread] |