bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] Does gawk optimize length(row) in for-loop?


From: Peng Yu
Subject: [bug-gawk] Does gawk optimize length(row) in for-loop?
Date: Sat, 25 Mar 2017 13:00:39 -0500

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]