Closed Bug 1695275 Opened 3 years ago Closed 3 years ago

PLDHashTable destructor does not need to iterate through entries when entry is trivially destructible

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(2 files, 1 obsolete file)

It seems unnecessary to zero the memory of removed entries such as is done by PLDHashTable::ClearEntryStub.
nsTHashtable::s_ClearEntry is already a no-op if EntryType is trivially destructible.

When we know that the clear operation is a no-op, we can skip iterating through all entries in PLDHashTable::~PLDHashTable entirely.

Assignee: nobody → sgiesecke
Status: NEW → ASSIGNED

One thing I might have missed here is that when not clearing, but removing individual entries, it might be necessary to either zero them on removal or on initialization. This seems to be the case for XPCMaps, e.g.

Attachment #9205751 - Attachment description: Bug 1695275 - Simplify hashtable clearing when EntryType is trivially destructible. r=#xpcom-reviewers → Bug 1695275 - Simplify hashtable clearing when there is no Clear operation. r=#xpcom-reviewers
Attachment #9205755 - Attachment is obsolete: true
Pushed by sgiesecke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/affdc2d452ce
Simplify hashtable clearing when there is no Clear operation. r=xpcom-reviewers,nika
https://hg.mozilla.org/integration/autoland/rev/945a04ae3805
Simplify hashtable clearing when EntryType is trivially destructible. r=xpcom-reviewers,nika
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: