Specifically, say I have a type with say 10 fields (mixture of strings, ints and floats and types) and I don't specify any default values for my fields, like this:
I assume that Bmax will just allocate a memory block that is all zeros with a simple command, and thus the fields will be zeroed or null (in the case of strings/type pointers etc). This should be pretty quick right? Does anyone know if it ACTUALLY does this or if the data is left random (which is even faster).
So let's say I assign some default values to the fields instead:
Obviously I can't assign a type to Field4 because none exist yet (maybe I can but it would be stinky bad programming).
Anyway, I'm now assuming this would be slower as the BlitzMax type contructor will have to individually assign each value to each field.
HOWEVER, here's what I really want to know ... let's say I assign a default value of 0 or null to every field, will the constructor be intelligent and NOT individually assign zero to each field because it knows the memory that was allocated was zeroed already (this is an assumption which could be false, it may be full of random data)? Or will it be slower because it foolishly manually assigns zeros/nulls to already blank fields?
Anyone have any idea on this or done any tests?
I ask because it could make a different if you say make 100 particles each with 50 fields that are being individually initialised instead of block initialised with a zero mem copy...(yes I know I should have a particle pool of pre-created types, but I'm just theorising here...)
Type foo Field1% Field2# Field3$ Field4:AnotherType End Type
I assume that Bmax will just allocate a memory block that is all zeros with a simple command, and thus the fields will be zeroed or null (in the case of strings/type pointers etc). This should be pretty quick right? Does anyone know if it ACTUALLY does this or if the data is left random (which is even faster).
So let's say I assign some default values to the fields instead:
Type foo Field1%=0 Field2#=1 Field3$="hello" Field4:AnotherType=null End Type
Obviously I can't assign a type to Field4 because none exist yet (maybe I can but it would be stinky bad programming).
Anyway, I'm now assuming this would be slower as the BlitzMax type contructor will have to individually assign each value to each field.
HOWEVER, here's what I really want to know ... let's say I assign a default value of 0 or null to every field, will the constructor be intelligent and NOT individually assign zero to each field because it knows the memory that was allocated was zeroed already (this is an assumption which could be false, it may be full of random data)? Or will it be slower because it foolishly manually assigns zeros/nulls to already blank fields?
Anyone have any idea on this or done any tests?
I ask because it could make a different if you say make 100 particles each with 50 fields that are being individually initialised instead of block initialised with a zero mem copy...(yes I know I should have a particle pool of pre-created types, but I'm just theorising here...)