realbasic-nug
[Top] [All Lists]

Re: For/next and array ubounds: optimising performance

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: For/next and array ubounds: optimising performance
From: Charles Yeomans <charles at declareSub dot com>
Date: Thu, 17 May 2007 11:12:42 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BAY107-DAV180C664B689445FD6BCCB093330 at phx dot gbl> <F25669BE-45B2-49B0-A395-E874F62E93C2 at great-white-software dot com>
On May 17, 2007, at 11:03 AM, Norman Palardy wrote:

>
> On 17-May-07, at 7:14 AM, Daniel Stenning wrote:
>
>> This makes me wonder: -  Idoes Ubound use a method/function call to
>> get the
>> ubound value,  or does the RB generate code to directly access a
>> "property"
>> or variable holding the internal array size ?.
>
> It's a method call
>
> Try
>       dim someArray(-1) as integer
>       someArray.append 1
>       someArray.append 2
>
>       for i as integer = 0 to ubound(someArray)
>               someArray.append i
>       next
>
>> Naturally there would be some speed advantage to NOT using any
>> function to
>> get the size.
>
> Except the size can change :)


In which case you should not use a for-next loop, in general :)

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

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


<Prev in Thread] Current Thread [Next in Thread>