Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/string/nsTStringComparator.cpp
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
template <typename T>
8
int NS_FASTCALL
9
Compare(const mozilla::detail::nsTStringRepr<T>& aLhs,
10
        const mozilla::detail::nsTStringRepr<T>& aRhs,
11
        const nsTStringComparator<T>& comp)
12
3
{
13
3
  typedef typename nsTSubstring<T>::size_type size_type;
14
3
  typedef typename nsTSubstring<T>::const_iterator const_iterator;
15
3
16
3
  if (&aLhs == &aRhs) {
17
0
    return 0;
18
0
  }
19
3
20
3
  const_iterator leftIter, rightIter;
21
3
  aLhs.BeginReading(leftIter);
22
3
  aRhs.BeginReading(rightIter);
23
3
24
3
  size_type lLength = aLhs.Length();
25
3
  size_type rLength = aRhs.Length();
26
3
  size_type lengthToCompare = XPCOM_MIN(lLength, rLength);
27
3
28
3
  int result;
29
3
  if ((result = comp(leftIter.get(), rightIter.get(),
30
3
                     lengthToCompare, lengthToCompare)) == 0) {
31
0
    if (lLength < rLength) {
32
0
      result = -1;
33
0
    } else if (rLength < lLength) {
34
0
      result = 1;
35
0
    } else {
36
0
      result = 0;
37
0
    }
38
0
  }
39
3
40
3
  return result;
41
3
}
int Compare<char>(mozilla::detail::nsTStringRepr<char> const&, mozilla::detail::nsTStringRepr<char> const&, nsTStringComparator<char> const&)
Line
Count
Source
12
3
{
13
3
  typedef typename nsTSubstring<T>::size_type size_type;
14
3
  typedef typename nsTSubstring<T>::const_iterator const_iterator;
15
3
16
3
  if (&aLhs == &aRhs) {
17
0
    return 0;
18
0
  }
19
3
20
3
  const_iterator leftIter, rightIter;
21
3
  aLhs.BeginReading(leftIter);
22
3
  aRhs.BeginReading(rightIter);
23
3
24
3
  size_type lLength = aLhs.Length();
25
3
  size_type rLength = aRhs.Length();
26
3
  size_type lengthToCompare = XPCOM_MIN(lLength, rLength);
27
3
28
3
  int result;
29
3
  if ((result = comp(leftIter.get(), rightIter.get(),
30
3
                     lengthToCompare, lengthToCompare)) == 0) {
31
0
    if (lLength < rLength) {
32
0
      result = -1;
33
0
    } else if (rLength < lLength) {
34
0
      result = 1;
35
0
    } else {
36
0
      result = 0;
37
0
    }
38
0
  }
39
3
40
3
  return result;
41
3
}
Unexecuted instantiation: int Compare<char16_t>(mozilla::detail::nsTStringRepr<char16_t> const&, mozilla::detail::nsTStringRepr<char16_t> const&, nsTStringComparator<char16_t> const&)
42
43
template <typename T>
44
int
45
nsTDefaultStringComparator<T>::operator()(const char_type* aLhs,
46
                                          const char_type* aRhs,
47
                                          uint32_t aLLength,
48
                                          uint32_t aRLength) const
49
273k
{
50
273k
  return
51
273k
    aLLength == aRLength ? nsCharTraits<T>::compare(aLhs, aRhs, aLLength) :
52
273k
                            (aLLength > aRLength) ? 1 : -1;
53
273k
}
nsTDefaultStringComparator<char>::operator()(char const*, char const*, unsigned int, unsigned int) const
Line
Count
Source
49
273k
{
50
273k
  return
51
273k
    aLLength == aRLength ? nsCharTraits<T>::compare(aLhs, aRhs, aLLength) :
52
273k
                            (aLLength > aRLength) ? 1 : -1;
53
273k
}
Unexecuted instantiation: nsTDefaultStringComparator<char16_t>::operator()(char16_t const*, char16_t const*, unsigned int, unsigned int) const