#177508 - brave_orakio - Mon Jul 16, 2012 8:21 pm
Hi guys.
I`m getting some seemingly random copy error when I implement a copy loop.
I`m not sure if I brain farted here but isn`t this
the same as this:
You might be asking, "well orakio, why would you be using such a slow copy anyway?"
Well the original thing I was going for is is
the incremental version(which works like expected):
is much slower thanks to the i+5<cnt compare part.
_________________
help me
I`m getting some seemingly random copy error when I implement a copy loop.
I`m not sure if I brain farted here but isn`t this
Code: |
copy(const u16* src, u16* dest, cnt) { int i; for(i = cnt - 1; i >=0; i--) { dest[i] = src[i]; } } |
the same as this:
Code: |
copy(const u16* src, u16* dest, cnt) { int i; for(i = 0; i < cnt; i++) { dest[i] = src[i]; } } |
You might be asking, "well orakio, why would you be using such a slow copy anyway?"
Well the original thing I was going for is is
Code: |
copy(const u16* src, u16* dest, cnt) { int i; for(i = cnt - 1; i >=4; i-=5) { dest[i] = src[i]; dest[i - 1] = src[i - 1]; dest[i - 2] = src[i - 2]; dest[i - 3] = src[i - 3]; dest[i - 4] = src[i - 4]; } for(i ; i >=0; i--) { dest[i] = src[i]; } } |
the incremental version(which works like expected):
Code: |
copy(const u16* src, u16* dest, cnt) { int i; for(i = 0; i + 5 < cnt; i+=5) { dest[i] = src[i]; dest[i + 1] = src[i + 1]; dest[i +2] = src[i + 2]; dest[i + 3] = src[i + 3]; dest[i + 4] = src[i + 4]; } for(i ; i <cnt; i++) { dest[i] = src[i]; } } |
is much slower thanks to the i+5<cnt compare part.
_________________
help me