GCC Code Coverage Report


Directory: ./
File: util/RegExCache.cpp
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 2 2 100.0%
Branches: 7 14 50.0%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2022 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the GPL v2 as described in the
10 * included LICENSE.GPL file.
11 */
12
13 #include "fpp-pch.h"
14
15 #include "RegExCache.h"
16
17 std::map<std::string, std::list<std::unique_ptr<std::regex>>> RegExCache::REGEX_CACHE;
18 std::mutex RegExCache::REGEX_CACHE_LOCK;
19
20
21 1279 RegExCache::RegExCache(const std::string &s) : regexString(s) {
22
1/2
✓ Branch 0 taken 1279 times.
✗ Branch 1 not taken.
1279 std::unique_lock<std::mutex> lock(REGEX_CACHE_LOCK);
23
1/2
✓ Branch 0 taken 1279 times.
✗ Branch 1 not taken.
1279 auto &l = REGEX_CACHE[regexString];
24
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1116 times.
1279 if (l.empty()) {
25
3/8
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 163 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
163 regex = new std::regex(s);
26 } else {
27 1116 regex = l.front().release();
28 1116 l.pop_front();
29 }
30 1279 }
31
32 1279 RegExCache::~RegExCache() {
33 1279 std::unique_lock<std::mutex> lock(REGEX_CACHE_LOCK);
34 1279 auto &l = REGEX_CACHE[regexString];
35 1279 l.emplace_back(regex);
36 1279 }
37
38