Subject: Re: CVS commit: src/sys/lib/libkern
To: None <source-changes@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: source-changes
Date: 11/23/2007 03:30:43
In article <4744FEE0.7020708@dtsp.co.nz>,
David Sainty  <David.Sainty@dtsp.co.nz> wrote:
>Joerg Sonnenberger wrote:
>> On Thu, Nov 22, 2007 at 12:15:47PM +0900, YAMAMOTO Takashi wrote:
>>   
>>>> On Thu, Nov 22, 2007 at 11:31:44AM +0900, YAMAMOTO Takashi wrote:
>>>>       
>>>>> how about returning the duplicate node rather than a boolean?
>>>>>         
>>>> I don't think that is a common use case. E.g. normally insert is used to
>>>> prepare a new node and a duplicate entry is an actual error. I can't
>>>> think of a good example where you want to replace the existing entry and
>>>> didn't check for that earlier.
>>>>
>>>> Joerg
>>>>       
>>> i'm not suggesting to automatically replace an existing node.
>>>     
>>
>> No, but for what other reason should it return a pointer to the existing
>> node?
>>
>>   
>Better reporting of the error? (Information about the existing node)
>
>It is also often cheaper to insert, and modify the existing node if
>present rather than query before insert, and then repeat the lookup for
>the insert operation too. It's also more "atomic friendly" than query +
>insert, should the tree be doing its own locking.

And more information is better than less.

christos