I have a routine which merges two halves of a buffer (which comes from a Merge Sort). I have attached the routine (because with comments it is a bit long).
loop.txt (1.9 KB)
The interesting bit is this:
for k in lo .. hi by s do
{
var tk : T;
// blah ... blah
else if y[i] <= t[j] then // copy one item from lower chunk
{
tk = y[i]; i += 1;
}
else// copy one item from upper chunk
{
tk = t[j]; j += s;
}
t[k] = tk;
}
When I change the first 3 lines to
for (k, tk) in zip(lo .. hi by s, t[lo .. hi by s])
{
and drop the line
t[k] = tk
It slowed down by 30+%. Maybe because I reference t[j] during the loop. Wow. I obviously do not use the zipper'ed variant. Is this expected? Definitely not urgent