btree icon indicating copy to clipboard operation
btree copied to clipboard

DeleteHint() equal to Delete(), intentional?

Open glycerine opened this issue 10 months ago • 1 comments

Thanks for publishing this library. It looks very nicely designed.

I noticed that in btree.go the DeleteHint() method is equivalent to Delete(), because it never passes on the hint. I wonder if this is a mistake or intended. Perhaps worth a comment in the code if this was really meant; I'm not sure why I should use hints then, if they are just ignored.

// DeleteHint deletes a value for a key using a path hint                           
// Returns the deleted value or nil if the key was not found.                       
func (tr *BTree) DeleteHint(key any, hint *PathHint) (prev any) {
    if key == nil {
        return nil
    }
    v, ok := tr.base.DeleteHint(key, nil) // <<<<<<< is this nil intentional, rather than hint?
    if !ok {
        return nil
    }
    return v
}

glycerine avatar Feb 21 '25 19:02 glycerine

That looks like a mistake.

tidwall avatar Feb 21 '25 21:02 tidwall