Closed Bug 1210871 Opened 9 years ago Closed 9 years ago

don't use reinterpret_cast in nsTHashtable.h

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

Details

Attachments

(1 file)

We don't need to reinterpret_cast when casting from void*, and we don't
need to reinterpret_cast when we're casting up and down a class
hierarchy.  static_cast takes care of those cases just fine, and doesn't
scare the reader into thinking that nsTHashtable is doing something
unusual.
Comment on attachment 8669036 [details] [diff] [review]
don't use reinterpret_cast in nsTHashtable.h

Review of attachment 8669036 [details] [diff] [review]:
-----------------------------------------------------------------

r=me assuming KeyTypePointer is required to actually be a pointer.

::: xpcom/glue/nsTHashtable.h
@@ +357,5 @@
>  template<class EntryType>
>  PLDHashNumber
>  nsTHashtable<EntryType>::s_HashKey(PLDHashTable* aTable, const void* aKey)
>  {
> +  return EntryType::HashKey(static_cast<const KeyTypePointer>(aKey));

Is it possible that KeyTypePointer could be defined as uintptr_t or some such (thus requiring the reinterpret_cast)? That seems unlikely, so if we just say that's not allowed it seems fine.
Attachment #8669036 - Flags: review?(erahm) → review+
https://hg.mozilla.org/mozilla-central/rev/0b186b6c5559
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: