Coverage Report

Created: 2025-10-09 07:07

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.97k
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
7.41k
  while (!prefix->empty()) {
16
6.59k
    char& c = prefix->back();
17
6.59k
    if (c == '\xff') {  // char literal avoids signed/unsigned.
18
3.44k
      prefix->pop_back();
19
3.44k
    } else {
20
3.15k
      ++c;
21
3.15k
      break;
22
3.15k
    }
23
6.59k
  }
24
3.97k
}
25
26
}  // namespace re2