Closed Bug 271343 Opened 20 years ago Closed 3 years ago

HashTable RemoveEntry should return boolean indicating whether it deleted sth or not

Categories

(Core :: XPCOM, defect, P3)

x86
All
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: vlad, Unassigned)

Details

Right now, RemoveEntry returns void, giving no indication whether the delete
succeeded or not.  Would be convenient to callers if it returned a boolean
indicating what happened.
nsHashPropertyBag would benefit from this.
Assignee: dougt → vladimir
QA Contact: xpcom
Assignee: vladimir → nobody
Priority: -- → P3

Not sure if this has changed since the bug was filed, but PLDHashtable::RemoveEntry and nsTHashtable::RemoveEntry accept a pointer to an entry. This is obtained using PLDHashtable::Search resp. nsTHashtable::GetEntry. If there's no entry for a key, these functions return nullptr, and it's not valid to pass nullptr to RemoveEntry, so RemoveEntry always removes an entry.

OTOH, nsBaseHashtable::Remove accepts a key and returns a bool as desired by the bug description.

Unless I misunderstand something here, I think this can be resolved.

Flags: needinfo?(vladimir)

Also, nsTHashtable::EnsureRemoved has the property you ask for.

Resolving sounds great, 14 years :)

Flags: needinfo?(vladimir)

All's well that ends well ;)

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.