Hi fellow-c0ders
i've got a short question. Does anyone know a trick how to set an entire bool-array to false.
I usually did this with a loop, but it just doesn't feel good. I need this quite often for initialization.
Anyone?
Thanx
Hi fellow-c0ders
i've got a short question. Does anyone know a trick how to set an entire bool-array to false.
I usually did this with a loop, but it just doesn't feel good. I need this quite often for initialization.
Anyone?
Thanx
Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.
This, of course, works with dynamic arrays as well.Code:var a: array [0..5] of boolean; begin fillchar(a, length(a)*sizeof(boolean), 0); end.
It might also be faster than your for-method since I guess fillchar deals
with the array as whole chunk of memory. So the code gets rid off
the jumps, comparisons and assignments a for loop needs.
great, i'm often using loops for it
From brazil (:
Pascal pownz!
Ok, I tried now.
Its indeed faster than a loop. The bigger the array is, the faster
fillchar gets compared to a loop.
edit: added a comma ^^
sorry for my english, its faster or slower or equal performance?Originally Posted by waran
From brazil (:
Pascal pownz!
Okay... i think he means this:
When using very big array's, fillchar can give a great performance boost.
When using smaller array's, the performance boost is less, when compared to the FOR loop.
I must say that the sentence is a litlle hard to understand, because of the absence of punctuation.
Hope you understand
Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.
thanks, so i will use it
From brazil (:
Pascal pownz!
Bookmarks