template setDateIndex*(sp, nDay: untyped, getCT: proc(i: int32): dword, bInRange,…
- User
template setDateIndex*(sp, nDay: untyped, getCT: proc(i: int32): dword, bInRange, bChange) = let sq = sp.sq #if sq.len > 0: #调用者自行判断sq.len 长度 var iDi = sp.di bChange = false
while iDi < sq.high.int32 and getCT(iDi+1) <= nDay: inc iDi
#echo "sp.di", sp.di, " iDi", iDi if sp.di != iDi: bChange = true sp.di = min(iDi, sq.high).int32
下面是调用的方法 if obGP.sqPow.sq.len > 0: proc getCT(i: int32): dword = obGP.sqPow.sq[i].powRec.m_time setDateIndex(obGP.sqPow, nDay, getCT, bInRange, bChange)
上面的代码是由nim语言编写的,我的问题是
- getCT会被编译成{.inline.}吗? 如果不是inline的话会不会影响速度
- getCT的写法有没有办法写成lambdas
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.