Le 15 févr. 07, à 21:14, [EMAIL PROTECTED] a écrit :

On Feb 15, 2007, at 20:01 UTC, Octave Julien wrote:

I'm using a method that analyses a text given as an argument and
returns a two-dimensional array. This array has 5 columns, one filled
with strings, two with integers, and three with booleans. The
returned  array is defined as an array of type variant.

Yikes.  You're giving up an awful lot of type-safety there, as well as
making the computer work harder than it should have to.

With the same sample text it used
to work very  fast with a function filling up 6 different one
-dimensional arrays  defined before calling the method and given as
arguments.

Plus, with that approach, you maintain type safety.  I think that was a
much better solution than your current approach.  Alternatively, define
a class that has these arrays as properties, and have your analysis
method return an instance of this class.  But quit using Variant --
that's a hack really only appropriate for cases where the type can't be
known (for example, with the Dictionary class).  You know your data
types, so its use is not a good idea.

So my question is : is it slower because I'm using a
multidimensional  array, or because this array is defined with the
variant type ? Or both  ?

Probably because of using Variant, though I wouldn't expect *that* much
speed penalty.  Could also have something to do with your code and how
you're sizing the array.

Best,
- Joe


Thanks for your answer, Joe. As you suggest, my code is probably the bottleneck of the process. Since I just can't append new rows to the multi-dimensonal array, I had to redim it in a loop for each row (and I can hear hundreds of RealBasic veterans screaming as they read this...). Before trying your approach based on a custom class, I'd like to give another try to multi-dimensional arrays by rediming them once for all in my method. But can I ask you to elaborate on the type safety issue ? As a beginner I don't really get it, I'm afraid.
Thanks again.

Octave

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to