[FAQ] [V4Rb 2] VLink.FindLinked question

Ruslan Zasukhin sunshine at public.kherson.ua
Wed Jul 20 11:45:14 CDT 2005


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.

> 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.

I think you can get back your simple code using small utility function

    if( IsEmptyBitSet(res) )

And 

Sub IsEmptyBitSet( inRes as Vset )

    if inRes = nil or inRes.Count = 0
        return true
    else 
        return false
    return 

end


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list