LCOV - code coverage report
Current view: top level - xpcom/string - nsTDependentSubstring.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 31 36 86.1 %
Date: 2017-07-14 16:53:18 Functions: 8 12 66.7 %
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             : void
       8       54100 : nsTDependentSubstring_CharT::Rebind(const substring_type& str,
       9             :                                     uint32_t startPos, uint32_t length)
      10             : {
      11             :   // If we currently own a buffer, release it.
      12       54100 :   Finalize();
      13             : 
      14       54100 :   size_type strLength = str.Length();
      15             : 
      16       54100 :   if (startPos > strLength) {
      17           0 :     startPos = strLength;
      18             :   }
      19             : 
      20       54100 :   mData = const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos;
      21       54100 :   mLength = XPCOM_MIN(length, strLength - startPos);
      22       54100 :   mDataFlags = DataFlags(0);
      23       54100 : }
      24             : 
      25             : void
      26       15123 : nsTDependentSubstring_CharT::Rebind(const char_type* data, size_type length)
      27             : {
      28       15123 :   NS_ASSERTION(data, "nsTDependentSubstring must wrap a non-NULL buffer");
      29             : 
      30             :   // If we currently own a buffer, release it.
      31       15123 :   Finalize();
      32             : 
      33       15123 :   mData = const_cast<char_type*>(static_cast<const char_type*>(data));
      34       15123 :   mLength = length;
      35       15123 :   mDataFlags = DataFlags(0);
      36       15123 : }
      37             : 
      38             : void
      39           0 : nsTDependentSubstring_CharT::Rebind(const char_type* aStart, const char_type* aEnd)
      40             : {
      41           0 :   MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
      42           0 :   Rebind(aStart, size_type(aEnd - aStart));
      43           0 : }
      44             : 
      45       26825 : nsTDependentSubstring_CharT::nsTDependentSubstring_CharT(const char_type* aStart,
      46       26825 :                                                          const char_type* aEnd)
      47       26825 :   : substring_type(const_cast<char_type*>(aStart), uint32_t(aEnd - aStart),
      48       26825 :                    DataFlags(0), ClassFlags(0))
      49             : {
      50       26825 :   MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
      51       26825 : }
      52             : 
      53             : #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
      54             : nsTDependentSubstring_CharT::nsTDependentSubstring_CharT(char16ptr_t aStart,
      55             :                                                          char16ptr_t aEnd)
      56             :   : nsTDependentSubstring_CharT(static_cast<const char16_t*>(aStart),
      57             :                                 static_cast<const char16_t*>(aEnd))
      58             : {
      59             :   MOZ_RELEASE_ASSERT(static_cast<const char16_t*>(aStart) <=
      60             :                      static_cast<const char16_t*>(aEnd),
      61             :                      "Overflow!");
      62             : }
      63             : #endif
      64             : 
      65           4 : nsTDependentSubstring_CharT::nsTDependentSubstring_CharT(const const_iterator& aStart,
      66           4 :                                                          const const_iterator& aEnd)
      67           4 :   : substring_type(const_cast<char_type*>(aStart.get()),
      68           4 :                    uint32_t(aEnd.get() - aStart.get()),
      69           8 :                    DataFlags(0), ClassFlags(0))
      70             : {
      71           4 :   MOZ_RELEASE_ASSERT(aStart.get() <= aEnd.get(), "Overflow!");
      72           4 : }
      73             : 
      74             : const nsTDependentSubstring_CharT
      75       11293 : Substring(const CharT* aStart, const CharT* aEnd)
      76             : {
      77       11293 :   MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
      78       11293 :   return nsTDependentSubstring_CharT(aStart, aEnd);
      79             : }

Generated by: LCOV version 1.13