Coverage Report

Created: 2025-11-16 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/re2/util/strutil.cc
Line
Count
Source
1
// Copyright 1999-2005 The RE2 Authors.  All Rights Reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
5
#include "util/strutil.h"
6
7
namespace re2 {
8
9
3.10k
void PrefixSuccessor(std::string* prefix) {
10
  // We can increment the last character in the string and be done
11
  // unless that character is 255, in which case we have to erase the
12
  // last character and increment the previous character, unless that
13
  // is 255, etc. If the string is empty or consists entirely of
14
  // 255's, we just return the empty string.
15
5.94k
  while (!prefix->empty()) {
16
5.30k
    char& c = prefix->back();
17
5.30k
    if (c == '\xff') {  // char literal avoids signed/unsigned.
18
2.83k
      prefix->pop_back();
19
2.83k
    } else {
20
2.46k
      ++c;
21
2.46k
      break;
22
2.46k
    }
23
5.30k
  }
24
3.10k
}
25
26
}  // namespace re2