Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsAlgorithm.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef nsAlgorithm_h___
8
#define nsAlgorithm_h___
9
10
#include "nsCharTraits.h"  // for |nsCharSourceTraits|, |nsCharSinkTraits|
11
12
template <class T>
13
inline T
14
NS_ROUNDUP(const T& aA, const T& aB)
15
0
{
16
0
  return ((aA + (aB - 1)) / aB) * aB;
17
0
}
18
19
// We use these instead of std::min/max because we can't include the algorithm
20
// header in all of XPCOM because the stl wrappers will error out when included
21
// in parts of XPCOM. These functions should never be used outside of XPCOM.
22
template <class T>
23
inline const T&
24
XPCOM_MIN(const T& aA, const T& aB)
25
108M
{
26
108M
  return aB < aA ? aB : aA;
27
108M
}
unsigned long const& XPCOM_MIN<unsigned long>(unsigned long const&, unsigned long const&)
Line
Count
Source
25
65.8M
{
26
65.8M
  return aB < aA ? aB : aA;
27
65.8M
}
unsigned int const& XPCOM_MIN<unsigned int>(unsigned int const&, unsigned int const&)
Line
Count
Source
25
42.4M
{
26
42.4M
  return aB < aA ? aB : aA;
27
42.4M
}
long const& XPCOM_MIN<long>(long const&, long const&)
Line
Count
Source
25
71
{
26
71
  return aB < aA ? aB : aA;
27
71
}
int const& XPCOM_MIN<int>(int const&, int const&)
Line
Count
Source
25
53
{
26
53
  return aB < aA ? aB : aA;
27
53
}
Unexecuted instantiation: float const& XPCOM_MIN<float>(float const&, float const&)
Unexecuted instantiation: double const& XPCOM_MIN<double>(double const&, double const&)
Unexecuted instantiation: mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const& XPCOM_MIN<mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> >(mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&, mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&)
28
29
// Must return b when a == b in case a is -0
30
template <class T>
31
inline const T&
32
XPCOM_MAX(const T& aA, const T& aB)
33
2.63k
{
34
2.63k
  return aA > aB ? aA : aB;
35
2.63k
}
unsigned long const& XPCOM_MAX<unsigned long>(unsigned long const&, unsigned long const&)
Line
Count
Source
33
3
{
34
3
  return aA > aB ? aA : aB;
35
3
}
Unexecuted instantiation: long const& XPCOM_MAX<long>(long const&, long const&)
unsigned int const& XPCOM_MAX<unsigned int>(unsigned int const&, unsigned int const&)
Line
Count
Source
33
2.58k
{
34
2.58k
  return aA > aB ? aA : aB;
35
2.58k
}
int const& XPCOM_MAX<int>(int const&, int const&)
Line
Count
Source
33
53
{
34
53
  return aA > aB ? aA : aB;
35
53
}
Unexecuted instantiation: float const& XPCOM_MAX<float>(float const&, float const&)
Unexecuted instantiation: double const& XPCOM_MAX<double>(double const&, double const&)
Unexecuted instantiation: mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const& XPCOM_MAX<mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> >(mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&, mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&)
36
37
namespace mozilla {
38
39
template <class T>
40
inline const T&
41
clamped(const T& aA, const T& aMin, const T& aMax)
42
57
{
43
57
  MOZ_ASSERT(aMax >= aMin,
44
57
             "clamped(): aMax must be greater than or equal to aMin");
45
57
  return XPCOM_MIN(XPCOM_MAX(aA, aMin), aMax);
46
57
}
int const& mozilla::clamped<int>(int const&, int const&, int const&)
Line
Count
Source
42
53
{
43
53
  MOZ_ASSERT(aMax >= aMin,
44
53
             "clamped(): aMax must be greater than or equal to aMin");
45
53
  return XPCOM_MIN(XPCOM_MAX(aA, aMin), aMax);
46
53
}
unsigned int const& mozilla::clamped<unsigned int>(unsigned int const&, unsigned int const&, unsigned int const&)
Line
Count
Source
42
4
{
43
4
  MOZ_ASSERT(aMax >= aMin,
44
4
             "clamped(): aMax must be greater than or equal to aMin");
45
4
  return XPCOM_MIN(XPCOM_MAX(aA, aMin), aMax);
46
4
}
Unexecuted instantiation: float const& mozilla::clamped<float>(float const&, float const&, float const&)
Unexecuted instantiation: double const& mozilla::clamped<double>(double const&, double const&, double const&)
Unexecuted instantiation: mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const& mozilla::clamped<mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> >(mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&, mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&, mozilla::gfx::ScaleFactor<mozilla::LayoutDevicePixel, mozilla::ScreenPixel> const&)
Unexecuted instantiation: long const& mozilla::clamped<long>(long const&, long const&, long const&)
47
48
} // namespace mozilla
49
50
template <class InputIterator, class T>
51
inline uint32_t
52
NS_COUNT(InputIterator& aFirst, const InputIterator& aLast, const T& aValue)
53
18
{
54
18
  uint32_t result = 0;
55
195
  for (; aFirst != aLast; ++aFirst)
56
177
    if (*aFirst == aValue) {
57
18
      ++result;
58
18
    }
59
18
  return result;
60
18
}
unsigned int NS_COUNT<char const*, char>(char const*&, char const* const&, char const&)
Line
Count
Source
53
18
{
54
18
  uint32_t result = 0;
55
195
  for (; aFirst != aLast; ++aFirst)
56
177
    if (*aFirst == aValue) {
57
18
      ++result;
58
18
    }
59
18
  return result;
60
18
}
Unexecuted instantiation: unsigned int NS_COUNT<char16_t const*, char16_t>(char16_t const*&, char16_t const* const&, char16_t const&)
61
62
#endif // !defined(nsAlgorithm_h___)