[FAQ] [V4Rb 2] VLink.FindLinked question

Charles Yeomans yeomans at desuetude.com
Tue Jul 19 18:30:08 CDT 2005


On Jul 19, 2005, at 5:48 PM, Ruslan Zasukhin wrote:

> On 7/20/05 12:29 AM, "Charles Yeomans" <yeomans at desuetude.com> 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.  And even this overhead could be reduced by keeping 
a reference to a single VArraySet with 0 elements to return any time 
it's needed.

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



More information about the Valentina mailing list