[FAQ] [V4Rb 2] VLink.FindLinked question

Charles Yeomans yeomans at desuetude.com
Wed Jul 20 13:55:20 CDT 2005


On Jul 20, 2005, at 4:45 AM, Ruslan Zasukhin wrote:

> Hi Charles,
>
>>>> Why does VLink.FindLinked return nil if no matches are found, 
>>>> instead
>>>> of a VArraySet with 0 elements?  It certainly seems to me that the
>>>> better way would be to always return a non-nil object.
>>>
>>> This was made on C++ level, and repeated in all plugins.
>>>
>>> Reason -- speed, less RAM resources, ...
>>>
>>> Why spend time and RAM
>>>     to create empty array,
>>>     later to destroy it
>>>     on call of function get_Count() to see that it is empty
>>>
>>> ?
>>>
>>> Instead we have simple
>>>
>>>     res = field.find
>>>
>>>     if( res = nil )
>>>         return  // or else you want
>>
>> Well, instead I have to spend time checking whether FindLinked returns
>> nil, which complicates my code in some situations.
>
>> I know that Valentina is fast, but surely searching is not typically 
>> faster
>> than creating an object.
>
> Not a fact. RAM allocations is not so light operation.
>
> In C++ world exists even special ways to develop own pools to have 
> faster
> allocation of RAM then default system function do.
>
> You can have task where you do loop 100,000 times, get from T1 some 
> info,
> And do search in T2.

Hmmm; I have to defer to you on questions of efficiency in C++.

My next question -- the documentation lists two versions of 
VLink.FindLinked; one returns a VArraySet, and one returns a VBitSet.  
Since REALbasic doesn't usually permit two functions having the same 
signature to have different return types, I'm confused.

--------------
Charles Yeomans



More information about the Valentina mailing list