LCOV - code coverage report
Current view: top level - xpcom/ds - nsPointerHashKeys.h (source / functions) Hit Total Coverage
Test: output.info Lines: 7 8 87.5 %
Date: 2017-07-14 16:53:18 Functions: 94 588 16.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : /* Definitions for nsPtrHashKey<T> and nsVoidPtrHashKey.  */
       8             : 
       9             : #ifndef nsPointerHashKeys_h
      10             : #define nsPointerHashKeys_h
      11             : 
      12             : #include "nscore.h"
      13             : 
      14             : #include "mozilla/Attributes.h"
      15             : 
      16             : /**
      17             :  * hashkey wrapper using T* KeyType
      18             :  *
      19             :  * @see nsTHashtable::EntryType for specification
      20             :  */
      21             : template<class T>
      22             : class nsPtrHashKey : public PLDHashEntryHdr
      23             : {
      24             : public:
      25             :   typedef T* KeyType;
      26             :   typedef const T* KeyTypePointer;
      27             : 
      28       20391 :   explicit nsPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {}
      29           0 :   nsPtrHashKey(const nsPtrHashKey<T>& aToCopy) : mKey(aToCopy.mKey) {}
      30        9458 :   ~nsPtrHashKey() {}
      31             : 
      32        1140 :   KeyType GetKey() const { return mKey; }
      33       53458 :   bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; }
      34             : 
      35       96950 :   static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
      36       91088 :   static PLDHashNumber HashKey(KeyTypePointer aKey)
      37             :   {
      38       91088 :     return uintptr_t(aKey) >> 2;
      39             :   }
      40             :   enum { ALLOW_MEMMOVE = true };
      41             : 
      42             : protected:
      43             :   T* MOZ_NON_OWNING_REF mKey;
      44             : };
      45             : 
      46             : typedef nsPtrHashKey<const void> nsVoidPtrHashKey;
      47             : 
      48             : #endif // nsPointerHashKeys_h

Generated by: LCOV version 1.13